Tasks #12232
radosgw-admin bucket stats give incorrect max_markers when bucket index sharding is enabled.
Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
% Done:
0%
Tags:
Reviewed:
Affected Versions:
Pull request ID:
Description
int RGWRados::get_bucket_stats(rgw_bucket& bucket, string *bucket_ver, string *master_ver,
map<RGWObjCategory, RGWStorageStats>& stats, string *max_marker)
{
map<string, rgw_bucket_dir_header> headers;
map<int, string> bucket_instance_ids;
int r = cls_bucket_head(bucket, headers, &bucket_instance_ids);
if (r < 0)
return r;
assert(headers.size() == bucket_instance_ids.size());
map<string, rgw_bucket_dir_header>::iterator iter = headers.begin();<<<<<The keys of the map are strings like ".dir.za.5124.2.1", ".dir.za.5124.2.2", ".dir.za.5124.2.10"
map<int, string>::iterator viter = bucket_instance_ids.begin();<<<<<<<<<<The keys of the map are integers like 0, 1, 2, 10
BucketIndexShardsManager ver_mgr;
BucketIndexShardsManager master_ver_mgr;
BucketIndexShardsManager marker_mgr;
char buf[64];
for(; iter != headers.end(); ++iter, ++viter) { <<<<<For integers, 2 will be before 10. But for strings, ".dir.za.5124.2.10" is before ".dir.za.5124.2.2" instead. Thus, the 2 iterators will go ahead in different orders and give incorrect results finally.
accumulate_raw_stats(iter->second, stats);
snprintf(buf, sizeof(buf), "%lu", iter->second.ver);
ver_mgr.add(viter->first, string(buf));
snprintf(buf, sizeof(buf), "%lu", iter->second.master_ver);
master_ver_mgr.add(viter->first, string(buf));
marker_mgr.add(viter->first, iter->second.max_marker);
}
ver_mgr.to_string(bucket_ver);
master_ver_mgr.to_string(master_ver);
marker_mgr.to_string(max_marker);
return 0;
}
History
#1 Updated by Loïc Dachary over 8 years ago
- Project changed from Stable releases to rgw