]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add context list for commit wait
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 13 Jul 2023 00:54:46 +0000 (20:54 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 21 Jul 2023 14:09:05 +0000 (10:09 -0400)
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 <pdonnell@redhat.com>
src/mon/PaxosService.cc
src/mon/PaxosService.h

index cfe11cb5049e836bd9529938db4bf72ace2e90aa..ce2c5977f2e2d76ac550e84c35515193c8b86b0c 100644 (file)
@@ -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();
index 7db6681e6666f1622b55cb63b8fb4e40f0f991b9..cf149ae69856349e85e1efc205c82327b043c998 100644 (file)
@@ -478,12 +478,17 @@ public:
    * @}
    */
 
+  /**
+   * Callback list to be used for waiting for the next proposal to commit.
+   */
+  std::vector<Context*> 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<Context*> waiting_for_finished_proposal;
+  std::vector<Context*> 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
    *