File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -609,9 +609,12 @@ func (b *batch) Replay(w ethdb.KeyValueWriter) error {
609609
610610// pebbleIterator is a wrapper of underlying iterator in storage engine.
611611// The purpose of this structure is to implement the missing APIs.
612+ //
613+ // The pebble iterator is not thread-safe.
612614type pebbleIterator struct {
613- iter * pebble.Iterator
614- moved bool
615+ iter * pebble.Iterator
616+ moved bool
617+ released bool
615618}
616619
617620// NewIterator creates a binary-alphabetical iterator over a subset
@@ -623,7 +626,7 @@ func (d *Database) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
623626 UpperBound : upperBound (prefix ),
624627 })
625628 iter .First ()
626- return & pebbleIterator {iter : iter , moved : true }
629+ return & pebbleIterator {iter : iter , moved : true , released : false }
627630}
628631
629632// Next moves the iterator to the next key/value pair. It returns whether the
@@ -658,4 +661,9 @@ func (iter *pebbleIterator) Value() []byte {
658661
659662// Release releases associated resources. Release should always succeed and can
660663// be called multiple times without causing error.
661- func (iter * pebbleIterator ) Release () { iter .iter .Close () }
664+ func (iter * pebbleIterator ) Release () {
665+ if ! iter .released {
666+ iter .iter .Close ()
667+ iter .released = true
668+ }
669+ }
You can’t perform that action at this time.
0 commit comments