Skip to content

Commit

Permalink
Fix state sync halt issue (#559)
Browse files Browse the repository at this point in the history
## Describe your changes and provide context
The issue is that when a node is exporting snapshot for wasm, it needs
to reopen the SC store for a given height, which could take 10-20
minutes, during that time, we acquired a lock which blocks the block
commit.

The fix is to fix the lock usage to only apply after we open the DB.
## Testing performed to validate your change
Tested on state sync node
  • Loading branch information
yzang2019 authored Jan 3, 2025
1 parent a11b106 commit beceb85
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions storev2/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,26 +279,26 @@ func (rs *Store) CacheMultiStoreForExport(version int64) (types.CacheMultiStore,
if version <= 0 || (rs.lastCommitInfo != nil && version == rs.lastCommitInfo.Version) {
return rs.CacheMultiStore(), nil
}
// Open SC stores for wasm snapshot, this op is blocking and could take a long time
scStore, err := rs.scStore.LoadVersion(version, true)
if err != nil {
return nil, err
}
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 {
if store.GetStoreType() != types.StoreTypeIAVL {
stores[k] = store
}
}
// add SC stores for historical queries
scStore, err := rs.scStore.LoadVersion(version, true)
if err != nil {
return nil, err
}
for k, store := range rs.ckvStores {
if store.GetStoreType() == types.StoreTypeIAVL {
tree := scStore.GetTreeByName(k.Name())
stores[k] = commitment.NewStore(tree, rs.logger)
}
}
rs.mtx.RUnlock()
cacheMs := cachemulti.NewStore(nil, stores, rs.storeKeys, nil, nil, nil)
// We need this because we need to make sure sc is closed after being used to release the resources
cacheMs.AddCloser(scStore)
Expand Down

0 comments on commit beceb85

Please sign in to comment.