From 81cfd5da3f7e6d889e6440c23227d8e78c8aa06f Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 28 Feb 2020 11:06:32 -0500 Subject: [PATCH] rgw: bucket_list_ordered advances past duplicate common prefixes we may see the same common prefix from more than one shard. when we detect a duplicate, we need to advance past it. otherwise, we may make the wrong decision about is_truncated because the shards with duplicates won't be at_end() Fixes: https://tracker.ceph.com/issues/44353 Signed-off-by: Casey Bodley --- src/rgw/rgw_rados.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 6142c9bd457..2e0a9f77c3c 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -8309,7 +8309,9 @@ int RGWRados::cls_bucket_list_ordered(RGWBucketInfo& bucket_info, // it's important that the values in the map refer to the index // into the results_trackers vector, which may not be the same // as the shard number (i.e., when not all shards are requested) - candidates[t.entry_name()] = tracker_idx; + if (!candidates.emplace(t.entry_name(), tracker_idx).second) { + t.advance(); // skip duplicate common prefixes + } } ++tracker_idx; } @@ -8367,7 +8369,9 @@ int RGWRados::cls_bucket_list_ordered(RGWBucketInfo& bucket_info, // refresh the candidates map candidates.erase(candidates.begin()); if (! tracker.advance().at_end()) { - candidates[tracker.entry_name()] = tracker_idx; + if (!candidates.emplace(tracker.entry_name(), tracker_idx).second) { + tracker.advance(); // skip duplicate common prefixes + } } else if (tracker.is_truncated()) { // once we exhaust one shard that is truncated, we need to stop, // as we cannot be certain that one of the next entries needs to -- 2.39.5