]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use new Stopped state for special handling of 'bucket sync disable' 33054/head
authorCasey Bodley <cbodley@redhat.com>
Mon, 3 Feb 2020 20:59:58 +0000 (15:59 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 5 Feb 2020 17:56:18 +0000 (12:56 -0500)
some sync modules like pubsub can disable full sync, and only run
incremental sync. without full sync, 'bucket sync disable/enable' will
continuously restart incremental sync from the beginning of the bilog

this adds a new Stopped state for 'bucket sync disable', which leaves the
incremental marker position where it is (just past the SYNCSTOP entry).
this means that when sync is reenabled, it can continue sync from where
it left off

Fixes: https://tracker.ceph.com/issues/43768
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_data_sync.cc
src/rgw/rgw_data_sync.h
src/rgw/rgw_json_enc.cc

index dddb0c6cecbda2c35233819fc3ab3d35189688e4..67cbd7aa2b1b041723248637a894430eb61b796e 100644 (file)
@@ -2768,21 +2768,35 @@ public:
       yield {
         auto store = sync_env->store;
         rgw_raw_obj obj(sync_env->svc->zone->get_zone_params().log_pool, sync_status_oid);
+        const bool stopped = status.state == rgw_bucket_shard_sync_info::StateStopped;
+        bool write_status = false;
 
         if (info.syncstopped) {
-          call(new RGWRadosRemoveCR(store, obj));
+          if (stopped && !sync_env->sync_module->should_full_sync()) {
+            // preserve our current incremental marker position
+            write_status = true;
+          }
         } else {
           // whether or not to do full sync, incremental sync will follow anyway
           if (sync_env->sync_module->should_full_sync()) {
             status.state = rgw_bucket_shard_sync_info::StateFullSync;
             status.inc_marker.position = info.max_marker;
           } else {
+            // clear the marker position unless we're resuming from SYNCSTOP
+            if (!stopped) {
+              status.inc_marker.position = "";
+            }
             status.state = rgw_bucket_shard_sync_info::StateIncrementalSync;
-            status.inc_marker.position = "";
           }
+          write_status = true;
+        }
+
+        if (write_status) {
           map<string, bufferlist> attrs;
           status.encode_all_attrs(attrs);
           call(new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, sync_env->svc->sysobj, obj, attrs));
+        } else {
+          call(new RGWRadosRemoveCR(store, obj));
         }
       }
       if (info.syncstopped) {
@@ -4085,11 +4099,11 @@ int RGWBucketShardIncrementalSyncCR::operate()
     tn->unset_flag(RGW_SNS_FLAG_ACTIVE);
 
     if (syncstopped) {
-      // transition back to StateInit in RGWRunBucketSyncCoroutine. if sync is
+      // transition to StateStopped in RGWRunBucketSyncCoroutine. if sync is
       // still disabled, we'll delete the sync status object. otherwise we'll
       // restart full sync to catch any changes that happened while sync was
       // disabled
-      sync_info.state = rgw_bucket_shard_sync_info::StateInit;
+      sync_info.state = rgw_bucket_shard_sync_info::StateStopped;
       return set_cr_done();
     }
 
@@ -4695,7 +4709,8 @@ int RGWRunBucketSyncCoroutine::operate()
     sync_pipe.info = sync_pair;
 
     do {
-      if (sync_status.state == rgw_bucket_shard_sync_info::StateInit) {
+      if (sync_status.state == rgw_bucket_shard_sync_info::StateInit ||
+          sync_status.state == rgw_bucket_shard_sync_info::StateStopped) {
         yield call(new RGWInitBucketShardSyncStatusCoroutine(sc, sync_pair, sync_status));
         if (retcode == -ENOENT) {
           tn->log(0, "bucket sync disabled");
index 29267ca40c45c741cc211949d01e744a3930894e..9a2174bed5c55f809531ad66a118e1e8386c42e4 100644 (file)
@@ -505,6 +505,7 @@ struct rgw_bucket_shard_sync_info {
     StateInit = 0,
     StateFullSync = 1,
     StateIncrementalSync = 2,
+    StateStopped = 3,
   };
 
   uint16_t state;
index f525c39893e995b96424f01a7dc9647eca406d56..1864f6cb63d7b5ab2b474a93bf0c42ca326eb992 100644 (file)
@@ -1803,6 +1803,9 @@ void rgw_bucket_shard_sync_info::dump(Formatter *f) const
   case StateIncrementalSync:
     s = "incremental-sync";
     break;
+  case StateStopped:
+    s = "stopped";
+    break;
   default:
     s = "unknown";
     break;