Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Bug Fixes

- [#1007](https://github.com/cosmos/iavl/pull/1007) Add the extra check for the reformatted root node in `GetNode`
- [#1106](https://github.com/cosmos/iavl/pull/1106) Fix unlock of unlocked mutex panic.

### Improvements

Expand Down
20 changes: 10 additions & 10 deletions batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ func (b *BatchWithFlusher) Set(key, value []byte) error {
return err
}
if batchSizeAfter > b.flushThreshold {
b.mtx.Unlock()
if err := b.Write(); err != nil {
if err := b.write(); err != nil {
return err
}
b.mtx.Lock()
}
return b.batch.Set(key, value)
}
Expand All @@ -79,19 +77,14 @@ func (b *BatchWithFlusher) Delete(key []byte) error {
return err
}
if batchSizeAfter > b.flushThreshold {
b.mtx.Unlock()
if err := b.Write(); err != nil {
if err := b.write(); err != nil {
return err
}
b.mtx.Lock()
}
return b.batch.Delete(key)
}

func (b *BatchWithFlusher) Write() error {
b.mtx.Lock()
defer b.mtx.Unlock()

func (b *BatchWithFlusher) write() error {
if err := b.batch.Write(); err != nil {
return err
}
Expand All @@ -102,6 +95,13 @@ func (b *BatchWithFlusher) Write() error {
return nil
}

func (b *BatchWithFlusher) Write() error {
b.mtx.Lock()
defer b.mtx.Unlock()

return b.write()
}

func (b *BatchWithFlusher) WriteSync() error {
b.mtx.Lock()
defer b.mtx.Unlock()
Expand Down