Skip to content

Commit

Permalink
fix: data race of latestVersion (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
cool-develope authored Sep 13, 2023
1 parent 6aff580 commit 4de71fd
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 4de71fd

Please sign in to comment.