Skip to content

Commit

Permalink
fix: commit the ndb in LoadVersionForOverwriting (backport #640) (#643)
Browse files Browse the repository at this point in the history
Co-authored-by: yihuang <[email protected]>
Co-authored-by: Marko <[email protected]>
  • Loading branch information
3 people authored Dec 7, 2022
1 parent f4499a9 commit 43560dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- [#640](https://github.com/cosmos/iavl/pull/640) commit `NodeDB` batch in `LoadVersionForOverwriting`.

## 0.19.4 (October 28, 2022)

- [#599](https://github.com/cosmos/iavl/pull/599) Populate ImmutableTree creation in copy function with missing field
Expand Down
7 changes: 7 additions & 0 deletions mutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,13 @@ func (tree *MutableTree) LoadVersionForOverwriting(targetVersion int64) (int64,
return latestVersion, err
}

// Commit the tree rollback first
// The fast storage rebuild don't have to be atomic with this,
// because it's idempotent and will do again when `LoadVersion`.
if err := tree.ndb.Commit(); err != nil {
return latestVersion, err
}

if !tree.skipFastStorageUpgrade {
if err := tree.enableFastStorageAndCommitLocked(); err != nil {
return latestVersion, err
Expand Down

0 comments on commit 43560dc

Please sign in to comment.