]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix loop problem with swift stat on account. 36185/head
authorMarcus Watts <mwatts@redhat.com>
Tue, 10 Mar 2020 04:34:01 +0000 (00:34 -0400)
committerNathan Cutler <ncutler@suse.com>
Sat, 18 Jul 2020 20:19:02 +0000 (22:19 +0200)
Loop logic in RGWStatAccount::execute was failing to change the
marker before repeating a call to rgw_read_user_buckets().  This resulted
that in the case that a user had more than 1000 buckets, this routine
would loop forever.

Fixes: https://tracker.ceph.com/issues/44671
Signed-off-by: Marcus Watts <mwatts@redhat.com>
(cherry picked from commit c9f3cf6ed6a649812d47dc1fa1357ae0749dbcbf)

Conflicts:
src/rgw/rgw_op.cc

src/rgw/rgw_op.cc

index a0c0e81801e5176dd0d2faa4ad2d6f2fafd06ba9..2f628d779cc6cd6e0adfc30849a7267e759b85f9 100644 (file)
@@ -2398,17 +2398,19 @@ void RGWStatAccount::execute()
   string marker;
   bool is_truncated = false;
   uint64_t max_buckets = s->cct->_conf->rgw_list_buckets_max_chunk;
+  const string *lastmarker;
 
   do {
     RGWUserBuckets buckets;
 
+    lastmarker = nullptr;
     op_ret = rgw_read_user_buckets(store, s->user->user_id, buckets, marker,
                                   string(), max_buckets, true, &is_truncated);
     if (op_ret < 0) {
       /* hmm.. something wrong here.. the user was authenticated, so it
          should exist */
-      ldpp_dout(this, 10) << "WARNING: failed on rgw_get_user_buckets uid="
-                       << s->user->user_id << dendl;
+      ldpp_dout(this, 10) << "WARNING: failed on rgw_read_user_buckets uid="
+                       << s->user->user_id << " ret=" << op_ret << dendl;
       break;
     } else {
       /* We need to have stats for all our policies - even if a given policy
@@ -2422,6 +2424,7 @@ void RGWStatAccount::execute()
       std::map<std::string, RGWBucketEnt>& m = buckets.get_buckets();
       for (const auto& kv : m) {
         const auto& bucket = kv.second;
+       lastmarker = &kv.first;
 
         global_stats.bytes_used += bucket.size;
         global_stats.bytes_used_rounded += bucket.size_rounded;
@@ -2438,6 +2441,12 @@ void RGWStatAccount::execute()
       global_stats.buckets_count += m.size();
 
     }
+    if (!lastmarker) {
+       lderr(s->cct) << "ERROR: rgw_read_user_buckets, stasis at marker="
+             << marker << " uid=" << s->user->user_id << dendl;
+       break;
+    }
+    marker = *lastmarker;
   } while (is_truncated);
 }