]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: bucket_list_ordered advances past duplicate common prefixes
authorCasey Bodley <cbodley@redhat.com>
Fri, 28 Feb 2020 16:06:32 +0000 (11:06 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 28 Feb 2020 18:02:54 +0000 (13:02 -0500)
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 <cbodley@redhat.com>
src/rgw/rgw_rados.cc

index 6142c9bd457a09af5e389960554c6217c2930908..2e0a9f77c3c232a7259b74b319b0677f06e0585c 100644 (file)
@@ -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