From 7aec13f749035b9bef5e398c1ac3d56ceec8eb81 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 18 Mar 2013 21:00:06 -0700 Subject: [PATCH] mon/PaxosService: fix proposal waiter handling - Cancel the propsal waiters with EAGAIN on election, etc. - Drop the wakeup helper and open-code the one caller. Signed-off-by: Sage Weil Reviewed-by: Joao Eduardo Luis --- src/mon/PaxosService.cc | 25 ++++++++++--------------- src/mon/PaxosService.h | 5 ----- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index dc179d0ff62c6..a66c5ec061221 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -189,8 +189,8 @@ void PaxosService::restart() mon->timer.cancel_event(proposal_timer); proposal_timer = 0; } - // ignore any callbacks waiting for us to finish our proposal - waiting_for_finished_proposal.clear(); + + finish_contexts(g_ceph_context, waiting_for_finished_proposal, -EAGAIN); on_restart(); } @@ -210,8 +210,7 @@ void PaxosService::election_finished() } proposing.set(0); - // ignore any callbacks waiting for us to finish our proposal - waiting_for_finished_proposal.clear(); + finish_contexts(g_ceph_context, waiting_for_finished_proposal, -EAGAIN); // make sure we update our state if (is_active()) @@ -256,10 +255,11 @@ void PaxosService::_active() } } - /* wake people up before calling on_active(). We don't know how long we'll be - * on the service's on_active(), and we really should wake people up! - */ - wakeup_proposing_waiters(); + // wake up anyone who came in while we were proposing. note that + // anyone waiting for the previous proposal to commit is no longer + // on this list; it is on Paxos's. + finish_contexts(g_ceph_context, waiting_for_finished_proposal, 0); + // NOTE: it's possible that this will get called twice if we commit // an old paxos value. Implementations should be mindful of that. if (is_active()) @@ -275,8 +275,8 @@ void PaxosService::shutdown() mon->timer.cancel_event(proposal_timer); proposal_timer = 0; } - // ignore any callbacks waiting for us to finish our proposal - waiting_for_finished_proposal.clear(); + + finish_contexts(g_ceph_context, waiting_for_finished_proposal, -EAGAIN); } void PaxosService::put_version(MonitorDBStore::Transaction *t, @@ -298,11 +298,6 @@ int PaxosService::get_version(const string& prefix, version_t ver, return mon->store->get(get_service_name(), key, bl); } -void PaxosService::wakeup_proposing_waiters() -{ - finish_contexts(g_ceph_context, waiting_for_finished_proposal); -} - void PaxosService::trim(MonitorDBStore::Transaction *t, version_t from, version_t to) { diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index cfe764160edaa..30a7b6dfe51e5 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -560,11 +560,6 @@ public: wait_for_finished_proposal(c); } - /** - * Wakeup all the callbacks waiting for the proposal to be finished - */ - void wakeup_proposing_waiters(); - /** * @defgroup PaxosService_h_Trim * @{ -- 2.39.5