From: Patrick Donnelly Date: Thu, 13 Jul 2023 00:54:46 +0000 (-0400) Subject: mon: add context list for commit wait X-Git-Tag: v19.0.0~446^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dc8c321a3c75f3935b8fa9146b6f0859ad3b6e56;p=ceph.git mon: add context list for commit wait This will replace many uses of "wait_for_finished_proposal" where a reply is simply waiting for pending to commit. Signed-off-by: Patrick Donnelly --- diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index cfe11cb5049..ce2c5977f2e 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -142,9 +142,16 @@ bool PaxosService::dispatch(MonOpRequestRef op) void PaxosService::refresh(bool *need_bootstrap) { + dout(10) << __func__ << dendl; + // update cached versions - cached_first_committed = mon.store->get(get_service_name(), first_committed_name); - cached_last_committed = mon.store->get(get_service_name(), last_committed_name); + auto first_committed = mon.store->get(get_service_name(), first_committed_name); + auto last_committed = mon.store->get(get_service_name(), last_committed_name); + if (last_committed > cached_last_committed) { + finish_contexts(g_ceph_context, waiting_for_commit, 0); + } + cached_first_committed = first_committed; + cached_last_committed = last_committed; version_t new_format = get_value("format_version"); if (new_format != format_version) { @@ -153,7 +160,6 @@ void PaxosService::refresh(bool *need_bootstrap) } format_version = new_format; - dout(10) << __func__ << dendl; update_from_paxos(need_bootstrap); } @@ -164,8 +170,9 @@ void PaxosService::post_refresh() post_paxos_update(); - if (mon.is_peon() && !waiting_for_finished_proposal.empty()) { + if (mon.is_peon()) { finish_contexts(g_ceph_context, waiting_for_finished_proposal, -EAGAIN); + finish_contexts(g_ceph_context, waiting_for_commit, -EAGAIN); } } @@ -275,6 +282,7 @@ void PaxosService::restart() } finish_contexts(g_ceph_context, waiting_for_finished_proposal, -EAGAIN); + finish_contexts(g_ceph_context, waiting_for_commit, -EAGAIN); if (have_pending) { discard_pending(); @@ -290,6 +298,7 @@ void PaxosService::election_finished() dout(10) << __func__ << dendl; finish_contexts(g_ceph_context, waiting_for_finished_proposal, -EAGAIN); + finish_contexts(g_ceph_context, waiting_for_commit, -EAGAIN); // make sure we update our state _active(); @@ -367,6 +376,7 @@ void PaxosService::shutdown() proposal_timer = 0; } + finish_contexts(g_ceph_context, waiting_for_commit, -EAGAIN); finish_contexts(g_ceph_context, waiting_for_finished_proposal, -EAGAIN); on_shutdown(); diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index 7db6681e666..cf149ae6985 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -478,12 +478,17 @@ public: * @} */ + /** + * Callback list to be used for waiting for the next proposal to commit. + */ + std::vector waiting_for_commit; + /** * Callback list to be used whenever we are running a proposal through * Paxos. These callbacks will be awaken whenever the said proposal - * finishes. + * finishes **and** the PaxosService is active. */ - std::list waiting_for_finished_proposal; + std::vector waiting_for_finished_proposal; public: @@ -545,7 +550,21 @@ public: } /** - * Wait for a proposal to finish. + * Wait for a proposal to commit. + * + * Note: the proposal may not be signaled yet. This simply adds a context to + * be completed when the next proposal commits. + * + * @param c The callback to be awaken once the proposal is committed. + */ + void wait_for_commit(MonOpRequestRef op, Context *c) { + if (op) + op->mark_event(service_name + ":wait_for_commit"); + waiting_for_commit.push_back(c); + } + + /** + * Wait for a proposal to finish and PaxosService to become active. * * Add a callback to be awaken whenever our current proposal finishes being * proposed through Paxos. @@ -558,6 +577,7 @@ public: waiting_for_finished_proposal.push_back(c); } + /** * Wait for us to become active *