From 15ec7803926eac8bb81806977b3e769347abf4a7 Mon Sep 17 00:00:00 2001 From: Michael Butler Date: Thu, 7 Jul 2022 10:48:33 -0400 Subject: [PATCH] storage: close pebble iter gracefully when NewPebbleSSTIterator fails 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 #83984. To fix, this patch uses pebble.Close() to gracefully close the pebbleIterator if `pebble.NewExternalIter` fails. Release Note: None --- pkg/storage/pebble_iterator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/storage/pebble_iterator.go b/pkg/storage/pebble_iterator.go index ae562f498afb..8ea1a99477bb 100644 --- a/pkg/storage/pebble_iterator.go +++ b/pkg/storage/pebble_iterator.go @@ -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