Skip to content

Commit

Permalink
gc: fix NumKeysAffected counting more than collected
Browse files Browse the repository at this point in the history
Previously if key is not collected after a GC batch is sent out
it would still be included as affected in GC stats.
Those stats are mostly used for logging and tests, the unfortunate
effect is that randomized test could fail.
This commit fixes the bug.

Release note: None
  • Loading branch information
aliher1911 committed Jul 11, 2022
1 parent 7cfa5d4 commit bf86973
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/kv/kvserver/gc/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ func processReplicatedKeyRange(
}
if affected := isNewest && (sentBatchForThisKey || haveGarbageForThisKey); affected {
info.NumKeysAffected++
// If we reached newest timestamp for the key then we should reset sent
// batch to ensure subsequent keys are not included in affected keys if
// they don't have garbage.
sentBatchForThisKey = false
}
shouldSendBatch := batchGCKeysBytes >= KeyVersionChunkBytes
if shouldSendBatch || isNewest && haveGarbageForThisKey {
Expand Down

0 comments on commit bf86973

Please sign in to comment.