Merge pull request #36274 from xiexingguo/wip-peer-num-objects

osd/PeeringState: prevent peer's num_objects going negative

Reviewed-by: Neha Ojha <nojha@redhat.com>
Reviewed-by: yanjun <yan.jun8@zte.com.cn>
This commit is contained in:
Kefu Chai 2020-07-26 01:54:29 +08:00 committed by GitHub
commit 48a849299f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3276,7 +3276,8 @@ void PeeringState::update_calc_stats()
// Primary should not be in the peer_info, skip if it is.
if (peer.first == pg_whoami) continue;
int64_t missing = 0;
int64_t peer_num_objects = peer.second.stats.stats.sum.num_objects;
int64_t peer_num_objects =
std::max((int64_t)0, peer.second.stats.stats.sum.num_objects);
// Backfill targets always track num_objects accurately
// all other peers track missing accurately.
if (is_backfill_target(peer.first)) {