From: Casey Bodley Date: Thu, 25 May 2023 15:46:14 +0000 (-0400) Subject: Merge pull request #50841 from smanjara/fix-duplicate-objects-archive X-Git-Tag: v19.0.0~1128 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=856b743d8b9b5e14cdcb48579a9a6dc7ac069a33;p=ceph.git Merge pull request #50841 from smanjara/fix-duplicate-objects-archive rgw/archive: avoid duplicating objects when syncing from multiple zones Reviewed-by: Casey Bodley --- 856b743d8b9b5e14cdcb48579a9a6dc7ac069a33 diff --cc src/rgw/driver/rados/rgw_data_sync.cc index 4af21dc870f8,7e6e08fec355..651aa811eb5e --- a/src/rgw/driver/rados/rgw_data_sync.cc +++ b/src/rgw/driver/rados/rgw_data_sync.cc @@@ -3046,12 -3051,28 +3051,18 @@@ RGWCoroutine *RGWArchiveDataSyncModule: { auto sync_env = sc->env; ldout(sc->cct, 5) << "SYNC_ARCHIVE: sync_object: b=" << sync_pipe.info.source_bs.bucket << " k=" << key << " versioned_epoch=" << versioned_epoch.value_or(0) << dendl; - if (!sync_pipe.dest_bucket_info.versioned() || - (sync_pipe.dest_bucket_info.flags & BUCKET_VERSIONS_SUSPENDED)) { - ldout(sc->cct, 0) << "SYNC_ARCHIVE: sync_object: enabling object versioning for archive bucket" << dendl; - sync_pipe.dest_bucket_info.flags = (sync_pipe.dest_bucket_info.flags & ~BUCKET_VERSIONS_SUSPENDED) | BUCKET_VERSIONED; - int op_ret = sync_env->driver->getRados()->put_bucket_instance_info(sync_pipe.dest_bucket_info, false, real_time(), NULL, sync_env->dpp, null_yield); - if (op_ret < 0) { - ldpp_dout(sync_env->dpp, 0) << "SYNC_ARCHIVE: sync_object: error versioning archive bucket" << dendl; - return NULL; - } - } std::optional dest_key; + bool stat_follow_olh = false; + if (versioned_epoch.value_or(0) == 0) { /* force version if not set */ + stat_follow_olh = true; versioned_epoch = 0; dest_key = key; + if (key.instance.empty()) { + sync_env->driver->getRados()->gen_rand_obj_instance_name(&(*dest_key)); + } } if (key.instance.empty()) {