From: Marcus Watts Date: Tue, 10 Mar 2020 04:34:01 +0000 (-0400) Subject: rgw: fix loop problem with swift stat on account. X-Git-Tag: v14.2.11~49^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c355966fddc520804e74ec88c00c52b723dba5a2;p=ceph.git rgw: fix loop problem with swift stat on account. 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 (cherry picked from commit c9f3cf6ed6a649812d47dc1fa1357ae0749dbcbf) Conflicts: src/rgw/rgw_op.cc --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index a0c0e81801e51..2f628d779cc6c 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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& 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); }