Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return buffers after canceling badger operation #5796

Merged
merged 1 commit into from
Mar 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions blockstore/badger/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ func (b *Blockstore) PutMany(blocks []blocks.Block) error {
return ErrBlockstoreClosed
}

batch := b.DB.NewWriteBatch()
defer batch.Cancel()

// toReturn tracks the byte slices to return to the pool, if we're using key
// prefixing. we can't return each slice to the pool after each Set, because
// badger holds on to the slice.
Expand All @@ -304,6 +301,9 @@ func (b *Blockstore) PutMany(blocks []blocks.Block) error {
}()
}

batch := b.DB.NewWriteBatch()
defer batch.Cancel()

for _, block := range blocks {
k, pooled := b.PooledStorageKey(block.Cid())
if pooled {
Expand Down Expand Up @@ -342,9 +342,6 @@ func (b *Blockstore) DeleteMany(cids []cid.Cid) error {
return ErrBlockstoreClosed
}

batch := b.DB.NewWriteBatch()
defer batch.Cancel()

// toReturn tracks the byte slices to return to the pool, if we're using key
// prefixing. we can't return each slice to the pool after each Set, because
// badger holds on to the slice.
Expand All @@ -358,6 +355,9 @@ func (b *Blockstore) DeleteMany(cids []cid.Cid) error {
}()
}

batch := b.DB.NewWriteBatch()
defer batch.Cancel()

for _, cid := range cids {
k, pooled := b.PooledStorageKey(cid)
if pooled {
Expand Down