diff --git a/pkg/kv/kvserver/gc/gc.go b/pkg/kv/kvserver/gc/gc.go index 5fc168809869..fc9b42d63291 100644 --- a/pkg/kv/kvserver/gc/gc.go +++ b/pkg/kv/kvserver/gc/gc.go @@ -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 {