Skip to content

Commit

Permalink
fix: data race of latestVersion (backport #834) (#835)
Browse files Browse the repository at this point in the history
Co-authored-by: cool-developer <51834436+cool-develope@users.noreply.github.com>
  • Loading branch information
mergify[bot] and cool-develope authored Sep 13, 2023
1 parent f528c1f commit fdc599d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion mutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ func (tree *MutableTree) saveFastNodeVersion(isGenesis bool) error {
return tree.ndb.setFastStorageVersionToBatch()
}

// nolint: unused
func (tree *MutableTree) getUnsavedFastNodeAdditions() map[string]*fastnode.Node {
additions := make(map[string]*fastnode.Node)
tree.unsavedFastNodeAdditions.Range(func(key, value interface{}) bool {
Expand Down
2 changes: 2 additions & 0 deletions nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@ func (ndb *nodeDB) getLatestVersion() (int64, error) {
}

func (ndb *nodeDB) resetLatestVersion(version int64) {
ndb.mtx.Lock()
defer ndb.mtx.Unlock()
ndb.latestVersion = version
}

Expand Down

0 comments on commit fdc599d

Please sign in to comment.