Skip to content

Commit

Permalink
colblk: fix IndexIter.Close, add a defensive assertion in IndexIter
Browse files Browse the repository at this point in the history
A CI run observed a nil pointer in BlockHandleWithProperties during the
sstable.TestIterator_RandomErrors unit test. I haven't been able to reproduce
yet. This commit adds an invariants-build assertion that we're reading a valid
row.

Additionally, it fixes a bug in IndexIter.Close that could cause a subsequent
call to Valid() to return true.
  • Loading branch information
jbowens committed Oct 22, 2024
1 parent d9f7191 commit 6cca117
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sstable/colblk/index_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ func (i *IndexIter) applyTransforms(key []byte) []byte {
// BlockHandleWithProperties decodes the block handle with any encoded
// properties at the iterator's current position.
func (i *IndexIter) BlockHandleWithProperties() (block.HandleWithProperties, error) {
if invariants.Enabled && !i.Valid() {
panic(errors.AssertionFailedf("invalid row %d (n=%d)", i.row, i.n))
}
return block.HandleWithProperties{
Handle: block.Handle{
Offset: i.d.offsets.At(i.row),
Expand Down Expand Up @@ -382,6 +385,7 @@ func (i *IndexIter) Close() error {
i.h.Release()
i.h = block.BufferHandle{}
i.d = nil
i.n = 0
i.syntheticPrefixAndSuffix = block.SyntheticPrefixAndSuffix{}
return nil
}

0 comments on commit 6cca117

Please sign in to comment.