From 7934603544dc27dc223419fb6088c999dac5ad8e Mon Sep 17 00:00:00 2001 From: yzang2019 Date: Tue, 30 Jan 2024 08:09:35 +0800 Subject: [PATCH] Fix concurrent map access --- storev2/rootmulti/store.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storev2/rootmulti/store.go b/storev2/rootmulti/store.go index 89076e7d1..be7f4f2af 100644 --- a/storev2/rootmulti/store.go +++ b/storev2/rootmulti/store.go @@ -237,6 +237,8 @@ func (rs *Store) CacheMultiStoreWithVersion(version int64) (types.CacheMultiStor if version <= 0 || (rs.lastCommitInfo != nil && version == rs.lastCommitInfo.Version) { return rs.CacheMultiStore(), nil } + rs.mtx.RLock() + defer rs.mtx.RUnlock() stores := make(map[types.StoreKey]types.CacheWrapper) // add the transient/mem stores registered in current app. for k, store := range rs.ckvStores {