From 5434db9335ac23b96cc8d64c46e3d2eb78b68917 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 26 Feb 2016 16:23:54 -0500 Subject: [PATCH] rgw: use current period for InitSyncStatus the InitSyncStatus coroutine records the position to start incremental sync after finishing a full sync. this should be the master's marker from the current period, rather than its oldest log period this also adds a check to run_sync() that restarts a full sync if it sees that our sync period is behind the master's oldest log period Signed-off-by: Casey Bodley --- src/rgw/rgw_sync.cc | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index ab7a487fa8305..6b56dfcec875e 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -24,6 +24,9 @@ #define dout_subsys ceph_subsys_rgw +#undef dout_prefix +#define dout_prefix (*_dout << "rgw meta sync: ") + static string mdlog_sync_status_oid = "mdlog.sync-status"; static string mdlog_sync_status_shard_prefix = "mdlog.sync-status.shard"; static string mdlog_sync_full_sync_index_prefix = "meta.full-sync.index"; @@ -1639,8 +1642,11 @@ int RGWRemoteMetaLog::init_sync_status() return r; } sync_info.num_shards = mdlog_info.num_shards; - sync_info.period = mdlog_info.period; - sync_info.realm_epoch = mdlog_info.realm_epoch; + auto cursor = store->period_history->get_current(); + if (cursor) { + sync_info.period = cursor.get_period().get_id(); + sync_info.realm_epoch = cursor.get_epoch(); + } } RGWObjectCtx obj_ctx(store, NULL); @@ -1717,17 +1723,25 @@ int RGWRemoteMetaLog::run_sync() return r; } - if (!mdlog_info.period.empty() && sync_status.sync_info.period.empty()) { - // restart sync if the remote has a period but our status does not - sync_status.sync_info.state = rgw_meta_sync_info::StateInit; + if (!mdlog_info.period.empty()) { + // restart sync if the remote has a period, but: + // a) our status does not, or + // b) our sync period comes before the remote's oldest log period + if (sync_status.sync_info.period.empty() || + sync_status.sync_info.realm_epoch < mdlog_info.realm_epoch) { + sync_status.sync_info.state = rgw_meta_sync_info::StateInit; + } } if (sync_status.sync_info.state == rgw_meta_sync_info::StateInit) { ldout(store->ctx(), 20) << __func__ << "(): init" << dendl; sync_status.sync_info.num_shards = mdlog_info.num_shards; - // use the period/epoch from the master's oldest log - sync_status.sync_info.period = mdlog_info.period; - sync_status.sync_info.realm_epoch = mdlog_info.realm_epoch; + auto cursor = store->period_history->get_current(); + if (cursor) { + // run full sync, then start incremental from the current period/epoch + sync_status.sync_info.period = cursor.get_period().get_id(); + sync_status.sync_info.realm_epoch = cursor.get_epoch(); + } r = run(new RGWInitSyncStatusCoroutine(&sync_env, obj_ctx, sync_status.sync_info)); if (r == -EBUSY) { -- 2.39.5