Skip to content

Commit

Permalink
[SeiDB] Fix concurrent map access (#411)
Browse files Browse the repository at this point in the history
## Describe your changes and provide context
This should fix the concurrent map access for storeV2 root multistore
over (rs.ckvStores). The problem is that it is currently not protected
by a read lock so when other goroutine modify the map, it will throw
panic

## Testing performed to validate your change
  • Loading branch information
yzang2019 committed Feb 2, 2024
1 parent 66854d0 commit 9a72f36
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions storev2/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9a72f36

Please sign in to comment.