]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: 'bucket sync checkpoint' waits for full sync
authorCasey Bodley <cbodley@redhat.com>
Tue, 6 Oct 2020 21:59:39 +0000 (17:59 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 13 Sep 2021 16:27:48 +0000 (12:27 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_sync_checkpoint.cc

index bcb15683a3b6ace6cd346afb55b75319bcf88a5e..eb32198786e35373e90b18db66c121b666d90cfa 100644 (file)
@@ -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<rgw_bucket_shard_sync_info> status;
   status.resize(std::max<size_t>(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;
   }