From dcac9ba4592b8c2772b58a552afc56962c7e72f8 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 10 Nov 2015 15:33:39 -0800 Subject: [PATCH] rgw: initialize data sync if needed Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_data_sync.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index 60729756245ab..f8c4e7b15046c 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -1131,11 +1131,20 @@ int RGWRemoteDataLog::run_sync(int num_shards, rgw_data_sync_status& sync_status { RGWObjectCtx obj_ctx(store, NULL); + int r = run(new RGWReadDataSyncStatusCoroutine(async_rados, store, obj_ctx, source_zone, &sync_status)); + if (r == -ENOENT) { + r = run(new RGWInitDataSyncStatusCoroutine(async_rados, store, &http_manager, obj_ctx, source_zone, num_shards)); + } + if (r < 0) { + ldout(store->ctx(), 0) << "ERROR: failed to read sync status from source_zone=" << source_zone << " r=" << r << dendl; + return r; + } + lock.get_write(); data_sync_cr = new RGWDataSyncCR(store, &http_manager, async_rados, conn, store->get_zone_params().log_pool, source_zone); data_sync_cr->get(); lock.unlock(); - int r = run(data_sync_cr); + r = run(data_sync_cr); if (r < 0) { ldout(store->ctx(), 0) << "ERROR: failed to run sync" << dendl; return r; -- 2.39.5