From 3fa1cc7bbca6f0e5ee81b414037c66d33592e934 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 30 Oct 2015 17:34:06 -0700 Subject: [PATCH] rgw: move data sync init into the processing thread that way we don't depend on remote peer to be available Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_rados.cc | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 479ca3134c27b..3959af74bc676 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2696,16 +2696,23 @@ public: class RGWDataSyncProcessorThread : public RGWSyncProcessorThread { RGWDataSyncStatusManager sync; + bool initialized; uint64_t interval_msec() { - return 0; /* no interval associated, it'll run once until stopped */ + if (initialized) { + return 0; /* no interval associated, it'll run once until stopped */ + } else { +#define DATA_SYNC_INIT_WAIT_SEC 20 + return DATA_SYNC_INIT_WAIT_SEC; + } } void stop_process() { sync.stop(); } public: RGWDataSyncProcessorThread(RGWRados *_store, const string& _source_zone) : RGWSyncProcessorThread(_store), - sync(_store, _source_zone) {} + sync(_store, _source_zone), + initialized(false) {} void wakeup_sync_shards(map >& shard_ids) { for (map >::iterator iter = shard_ids.begin(); iter != shard_ids.end(); ++iter) { @@ -2713,16 +2720,21 @@ public: } } + int init() { - int ret = sync.init(); - if (ret < 0) { - ldout(store->ctx(), 0) << "ERROR: sync.init() returned " << ret << dendl; - return ret; - } return 0; } int process() { + while (!going_down()) { + int ret = sync.init(); + if (ret >= 0) { + initialized = true; + break; + } + /* we'll be back! */ + return 0; + } sync.run(); return 0; } -- 2.39.5