From b8af38b6fc161691d637631d9ce8ab84fb3d27c7 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 29 Jul 2013 17:14:57 -0700 Subject: [PATCH] mon: allow others to sync from us across bootstrap calls If someone is syncing from us and there is an election, they currently get reset and have to restart their sync. This can lead to situations where they can never finish, e.g., when the load from them syncing makes us time out commits and call elections. There is nothing that changes during bootstrap that would prevent a sync from proceeding. The only time we need to stop providing is when we ourselves decide to sync from someone else; modify that reset call to reset provider state. All other resets become requester resets. Signed-off-by: Sage Weil --- src/mon/Monitor.cc | 18 +++++++++++------- src/mon/Monitor.h | 10 +++++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 3b19b51405447..2c21e6eac69aa 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -619,7 +619,7 @@ void Monitor::bootstrap() { dout(10) << "bootstrap" << dendl; - sync_reset(); + sync_reset_requester(); unregister_cluster_logger(); cancel_probe_timeout(); @@ -806,23 +806,27 @@ void Monitor::sync_obtain_latest_monmap(bufferlist &bl) latest_monmap.encode(bl, CEPH_FEATURES_ALL); } -void Monitor::sync_reset() +void Monitor::sync_reset_requester() { + dout(10) << __func__ << dendl; + if (sync_timeout_event) { timer.cancel_event(sync_timeout_event); sync_timeout_event = NULL; } - // leader state - sync_providers.clear(); - - // requester state sync_provider = entity_inst_t(); sync_cookie = 0; sync_full = false; sync_start_version = 0; } +void Monitor::sync_reset_provider() +{ + dout(10) << __func__ << dendl; + sync_providers.clear(); +} + void Monitor::sync_start(entity_inst_t &other, bool full) { dout(10) << __func__ << " " << other << (full ? " full" : " recent") << dendl; @@ -832,7 +836,7 @@ void Monitor::sync_start(entity_inst_t &other, bool full) state = STATE_SYNCHRONIZING; // make sure are not a provider for anyone! - sync_reset(); + sync_reset_provider(); sync_full = full; diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index bed48ecee3436..35975e7a90f9b 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -301,10 +301,14 @@ private: set get_sync_targets_names(); /** - * Reset the monitor's sync-related data structures and state, both - * for the requester- and provider-side. + * Reset the monitor's sync-related data structures for syncing *from* a peer */ - void sync_reset(); + void sync_reset_requester(); + + /** + * Reset sync state related to allowing others to sync from us + */ + void sync_reset_provider(); /** * Caled when a sync attempt times out (requester-side) -- 2.39.5