Skip to content

Commit

Permalink
Fix merkledb rebuild iterator (#2581)
Browse files Browse the repository at this point in the history
  • Loading branch information
dboehm-avalabs authored Jan 4, 2024
1 parent 935bfe4 commit 72dc442
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion x/merkledb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ func (db *merkleDB) rebuild(ctx context.Context, cacheSize int) error {
)
currentOps := make([]database.BatchOp, 0, opsSizeLimit)
valueIt := db.NewIterator()
defer valueIt.Release()
// ensure valueIt is captured and release gets called on the latest copy of valueIt
defer func() { valueIt.Release() }()
for valueIt.Next() {
if len(currentOps) >= opsSizeLimit {
view, err := newView(db, db, ViewChanges{BatchOps: currentOps, ConsumeBytes: true})
Expand Down

0 comments on commit 72dc442

Please sign in to comment.