From 97eaa2999f08994d7d0f7c4436305220f4b5ee03 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 6 Oct 2020 17:59:39 -0400 Subject: [PATCH] radosgw-admin: 'bucket sync checkpoint' waits for full sync Signed-off-by: Casey Bodley --- src/rgw/rgw_sync_checkpoint.cc | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_sync_checkpoint.cc b/src/rgw/rgw_sync_checkpoint.cc index bcb15683a3b6a..eb32198786e35 100644 --- a/src/rgw/rgw_sync_checkpoint.cc +++ b/src/rgw/rgw_sync_checkpoint.cc @@ -31,9 +31,6 @@ namespace { std::string incremental_marker(const rgw_bucket_shard_sync_info& info) { - if (info.state != rgw_bucket_shard_sync_info::StateIncrementalSync) { - return ""; - } return BucketIndexShardsManager::get_shard_marker(info.inc_marker.position); } @@ -97,10 +94,31 @@ int bucket_source_sync_checkpoint(const DoutPrefixProvider* dpp, return 0; } + rgw_bucket_sync_status full_status; + int r = rgw_read_bucket_full_sync_status(dpp, store, pipe, &full_status, null_yield); + if (r < 0 && r != -ENOENT) { // retry on ENOENT + return r; + } + + while (full_status.state != BucketSyncState::Incremental) { + auto delay_until = ceph::coarse_mono_clock::now() + retry_delay; + if (delay_until > timeout_at) { + lderr(store->ctx()) << "bucket checkpoint timed out waiting to reach incremental sync" << dendl; + return -ETIMEDOUT; + } + ldout(store->ctx(), 1) << "waiting to reach incremental sync.." << dendl; + std::this_thread::sleep_until(delay_until); + + r = rgw_read_bucket_full_sync_status(dpp, store, pipe, &full_status, null_yield); + if (r < 0 && r != -ENOENT) { // retry on ENOENT + return r; + } + } + std::vector status; status.resize(std::max(1, num_shards)); - int r = rgw_read_bucket_inc_sync_status(dpp, store, pipe, bucket_info, - &source_bucket_info, &status); + r = rgw_read_bucket_inc_sync_status(dpp, store, pipe, bucket_info, + &source_bucket_info, &status); if (r < 0) { return r; } -- 2.39.5