Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: memiavl rootmulti store access map concurrently #1302

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
yihuang marked this conversation as resolved.
Show resolved Hide resolved
}

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
Loading