Skip to content

Commit

Permalink
storage: close pebble iter gracefully when NewPebbleSSTIterator fails
Browse files Browse the repository at this point in the history
Currently, if `pebble.NewExternalIter` sets pebbleIterator.inuse to True, but
then fails, the subsequent `pebbleIterator.destroy()` will panic unecessarily,
since the caller of `pebble.NewExternalIter` is not actually using the iter.
This bug causes TestBackupRestoreChecksum to flake in cockroachdb#83984.

To fix, this patch uses pebble.Close() to  gracefully close the pebbleIterator
if `pebble.NewExternalIter` fails.

Release Note: None
  • Loading branch information
msbutler committed Jul 7, 2022
1 parent 3b22cdd commit 15ec780
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/storage/pebble_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func newPebbleSSTIterator(files []sstable.ReadableFile, opts IterOptions) (*pebb

var err error
if p.iter, err = pebble.NewExternalIter(DefaultPebbleOptions(), &p.options, files); err != nil {
p.destroy()
p.Close()
return nil, err
}
return p, nil
Expand Down

0 comments on commit 15ec780

Please sign in to comment.