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 @@ -567,9 +567,12 @@ func (b *batch) Replay(w ethdb.KeyValueWriter) error {
567567
568568// pebbleIterator is a wrapper of underlying iterator in storage engine.
569569// The purpose of this structure is to implement the missing APIs.
570+ //
571+ // The pebble iterator is not thread-safe.
570572type pebbleIterator struct {
571- iter * pebble.Iterator
572- moved bool
573+ iter * pebble.Iterator
574+ moved bool
575+ released bool
573576}
574577
575578// NewIterator creates a binary-alphabetical iterator over a subset
@@ -581,7 +584,7 @@ func (d *Database) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
581584 UpperBound : upperBound (prefix ),
582585 })
583586 iter .First ()
584- return & pebbleIterator {iter : iter , moved : true }
587+ return & pebbleIterator {iter : iter , moved : true , released : false }
585588}
586589
587590// Next moves the iterator to the next key/value pair. It returns whether the
@@ -616,4 +619,9 @@ func (iter *pebbleIterator) Value() []byte {
616619
617620// Release releases associated resources. Release should always succeed and can
618621// be called multiple times without causing error.
619- func (iter * pebbleIterator ) Release () { iter .iter .Close () }
622+ func (iter * pebbleIterator ) Release () {
623+ if ! iter .released {
624+ iter .iter .Close ()
625+ iter .released = true
626+ }
627+ }
You can’t perform that action at this time.
0 commit comments