From d37b6e43dbee545278e7e668ced61f3f12c7287d Mon Sep 17 00:00:00 2001 From: Islam Aleiv Date: Thu, 22 Aug 2024 20:21:04 +0200 Subject: [PATCH] Close an existing iterator if it exists --- internal/db/fetcher/indexer_iterators.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/db/fetcher/indexer_iterators.go b/internal/db/fetcher/indexer_iterators.go index d5b239d7fa..5d9da70c9f 100644 --- a/internal/db/fetcher/indexer_iterators.go +++ b/internal/db/fetcher/indexer_iterators.go @@ -81,6 +81,11 @@ var _ indexIterator = (*indexPrefixIterator)(nil) func (iter *indexPrefixIterator) Init(ctx context.Context, store datastore.DSReaderWriter) error { iter.ctx = ctx iter.store = store + if iter.resultIter != nil { + if err := iter.resultIter.Close(); err != nil { + return err + } + } iter.resultIter = nil return nil }