From 550595a01723244d2a9a2c1e3f8029e9bf39bf9a Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 26 Mar 2021 11:00:57 -0400 Subject: [PATCH] rgw: reshard preserves old index in multisite if the old index is still referenced by an InIndex log layout, we can't call clean_index() to remove the index objects yet. log trimming will do that later, once the bilogs are no longer needed Signed-off-by: Casey Bodley --- src/rgw/rgw_reshard.cc | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_reshard.cc b/src/rgw/rgw_reshard.cc index b7a013df5021b..89f80e119eb4b 100644 --- a/src/rgw/rgw_reshard.cc +++ b/src/rgw/rgw_reshard.cc @@ -446,6 +446,24 @@ static int commit_reshard(rgw::sal::RadosStore* store, { auto& layout = bucket_info.layout; auto prev = layout; // make a copy for cleanup + const auto next_log_gen = layout.logs.back().gen + 1; + + bool remove_index = true; + + if (!store->svc()->zone->need_to_log_data()) { + // if we're not syncing data, we can drop any existing logs + layout.logs.clear(); + } else { + const auto last_index_gen = prev.current_index.gen; + for (const auto& log : layout.logs) { + if (log.layout.type == rgw::BucketLogType::InIndex && + log.layout.in_index.gen == last_index_gen) { + // we're storing logs in this index gen, we can't delete it yet + remove_index = false; + break; + } + } + } // use the new index layout as current ceph_assert(layout.target_index); @@ -453,7 +471,6 @@ static int commit_reshard(rgw::sal::RadosStore* store, layout.target_index = std::nullopt; layout.resharding = rgw::BucketReshardState::None; // add the in-index log layout - const auto next_log_gen = layout.logs.back().gen + 1; layout.logs.push_back(log_layout_from_index(next_log_gen, layout.current_index)); int ret = fault.check("commit_target_layout"); @@ -479,8 +496,9 @@ static int commit_reshard(rgw::sal::RadosStore* store, } // on success, delete index shard objects from the old layout (ignore errors) - store->svc()->bi->clean_index(dpp, bucket_info, prev.current_index); - + if (remove_index) { + store->svc()->bi->clean_index(dpp, bucket_info, prev.current_index); + } return 0; } // commit_reshard -- 2.39.5