From d8ed9f8e25dcdafac1975cadababa12df58ee98b Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 9 Mar 2022 07:38:36 -0800 Subject: [PATCH] fix concurrent map panic when querying and comittting concurrently --- mutable_tree.go | 2 -- nodedb.go | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mutable_tree.go b/mutable_tree.go index ff7ef346d..54dcfd54a 100644 --- a/mutable_tree.go +++ b/mutable_tree.go @@ -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 { @@ -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 { diff --git a/nodedb.go b/nodedb.go index 7bee811c5..716b33257 100644 --- a/nodedb.go +++ b/nodedb.go @@ -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 }