Skip to content

Commit

Permalink
fix concurrent map panic when querying and comittting concurrently
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn committed Mar 9, 2022
1 parent 2e0b26a commit d8ed9f8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 0 additions & 2 deletions mutable_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,6 @@ func (tree *MutableTree) getUnsavedFastNodeRemovals() map[string]interface{} {
func (tree *MutableTree) addUnsavedAddition(key []byte, node *FastNode) {
delete(tree.unsavedFastNodeRemovals, string(key))
tree.unsavedFastNodeAdditions[string(key)] = node
tree.ndb.cacheFastNode(node)
}

func (tree *MutableTree) saveFastNodeAdditions() error {
Expand All @@ -813,7 +812,6 @@ func (tree *MutableTree) saveFastNodeAdditions() error {
func (tree *MutableTree) addUnsavedRemoval(key []byte) {
delete(tree.unsavedFastNodeAdditions, string(key))
tree.unsavedFastNodeRemovals[string(key)] = true
tree.ndb.uncacheFastNode(key)
}

func (tree *MutableTree) saveFastNodeRemovals() error {
Expand Down
2 changes: 2 additions & 0 deletions nodedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ func (ndb *nodeDB) DeleteVersionsRange(fromVersion, toVersion int64) error {
}

func (ndb *nodeDB) DeleteFastNode(key []byte) error {
ndb.mtx.Lock()
defer ndb.mtx.Unlock()
if err := ndb.batch.Delete(ndb.fastNodeKey(key)); err != nil {
return err
}
Expand Down

0 comments on commit d8ed9f8

Please sign in to comment.