From de3fe89ebf5198d3191c5fefefa4adafb0e50fb8 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 5 May 2017 12:21:09 -0400 Subject: [PATCH] mon/Paxos: add plug/unplug Simple mechanism to prevent and immediate commit (until the caller does more stuff, presumably). Signed-off-by: Sage Weil --- src/mon/Paxos.cc | 5 ++++- src/mon/Paxos.h | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 8ba73118e0f0..08741b17170c 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -1539,7 +1539,10 @@ MonitorDBStore::TransactionRef Paxos::get_pending_transaction() bool Paxos::trigger_propose() { - if (is_active()) { + if (plugged) { + dout(10) << __func__ << " plugged, not proposing now" << dendl; + return false; + } else if (is_active()) { dout(10) << __func__ << " active, proposing now" << dendl; propose_pending(); return true; diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index 94046c86f1b1..4ba84e6cc45b 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -614,6 +614,11 @@ private: */ bool trimming; + /** + * true if we want trigger_propose to *not* propose (yet) + */ + bool plugged = false; + /** * @defgroup Paxos_h_callbacks Callback classes. * @{ @@ -1194,7 +1199,19 @@ public: return true; } - + + bool is_plugged() const { + return plugged; + } + void plug() { + assert(plugged == false); + plugged = true; + } + void unplug() { + assert(plugged == true); + plugged = false; + } + // read /** * @defgroup Paxos_h_read_funcs Read-related functions -- 2.47.3