Skip to content

Commit

Permalink
Problem: memiavl rootmulti store access map concurrently (#1302)
Browse files Browse the repository at this point in the history
* Problem: memiavl rootmulti store access map concurrently

Solution:
- code refactoring

* Update CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

---------

Signed-off-by: yihuang <huang@crypto.com>
  • Loading branch information
yihuang authored Jan 23, 2024
1 parent 8fc9446 commit 8fd18dc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- [#1292](https://github.com/crypto-org-chain/cronos/pull/1292) memiavl cancel background snapshot rewriting when graceful shutdown.
- [#1294](https://github.com/crypto-org-chain/cronos/pull/1294) Update ethermint to fix and improve of debug_traceCall and eth_feeHistory.
- [#1302](https://github.com/crypto-org-chain/cronos/pull/1302) Fix concurrent map access in rootmulti store.

*January 5, 2024*

Expand Down
4 changes: 4 additions & 0 deletions store/memiavlstore/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func New(tree *memiavl.Tree, logger log.Logger) *Store {
return &Store{tree: tree, logger: logger}
}

func (st *Store) SetTree(tree *memiavl.Tree) {
st.tree = tree
}

func (st *Store) Commit() types.CommitID {
panic("memiavl store is not supposed to be committed alone")
}
Expand Down
7 changes: 2 additions & 5 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,11 @@ func (rs *Store) Commit() types.CommitID {
panic(err)
}

// the underlying memiavl tree might be reloaded, reload the store as well.
// the underlying memiavl tree might be reloaded, update the tree.
for key := range rs.stores {
store := rs.stores[key]
if store.GetStoreType() == types.StoreTypeIAVL {
rs.stores[key], err = rs.loadCommitStoreFromParams(rs.db, key, rs.storesParams[key])
if err != nil {
panic(fmt.Errorf("inconsistent store map, store %s not found", key.Name()))
}
store.(*memiavlstore.Store).SetTree(rs.db.TreeByName(key.Name()))
}
}

Expand Down

0 comments on commit 8fd18dc

Please sign in to comment.