Skip to content

Commit

Permalink
storage: fix CheckSSTConflicts iterator misuse
Browse files Browse the repository at this point in the history
Fix a bug whereby CheckSSTConflicts could seek the engine iterator and seek
back, assuming that the originally returned buffers were still valid. This is
only true if RangeKeyChanged()=false after both seeks.

Backport of part of cockroachdb#97222.

Epic: None
Release note: None
  • Loading branch information
jbowens committed Feb 24, 2023
1 parent d7bcb56 commit 8b81e35
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/storage/sst.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,11 @@ func CheckSSTConflicts(
statsDiff.Add(updateStatsOnRangeKeyMerge(sstRangeKeys.Bounds.Key, sstRangeKeys.Versions))
}
extIter.SeekGE(savedExtKey)
// After seeking, the old buffers have been invalidated.
// Re-retrieve the buffers.
if extHasRange {
extRangeKeys = extIter.RangeKeys()
}
}
if extRangeKeysChanged && !sstPrevRangeKeys.IsEmpty() && sstPrevRangeKeys.Bounds.Overlaps(extRangeKeys.Bounds) {
// Because we always re-seek the extIter after every sstIter step,
Expand Down

0 comments on commit 8b81e35

Please sign in to comment.