Skip to content

Commit

Permalink
replace snapshot manager multistore with new one after DBSync (#229)
Browse files Browse the repository at this point in the history
## Describe your changes and provide context
Snapshot manager is initialized with the old multistore which is closed
when DBSync finishes. We need to replace the multistore with the new one
after DBSync so that snapshot manager can continue to work.

`SetMultiStore` should be safe to call in `ReloadDB` since no
snapshotting would be taking place during the call.

## Testing performed to validate your change
loadtest cluster
  • Loading branch information
codchen authored Apr 26, 2023
1 parent e6f0361 commit 355f18b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1118,5 +1118,8 @@ func (app *BaseApp) ReloadDB() error {
}
app.db = db
app.cms = store.NewCommitMultiStore(db)
if app.snapshotManager != nil {
app.snapshotManager.SetMultiStore(app.cms)
}
return nil
}
14 changes: 9 additions & 5 deletions snapshots/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ type restoreDone struct {
// Although the ABCI interface (and this manager) passes chunks as byte slices, the internal
// snapshot/restore APIs use IO streams (i.e. chan io.ReadCloser), for two reasons:
//
// 1) In the future, ABCI should support streaming. Consider e.g. InitChain during chain
// upgrades, which currently passes the entire chain state as an in-memory byte slice.
// https://github.com/tendermint/tendermint/issues/5184
// 1. In the future, ABCI should support streaming. Consider e.g. InitChain during chain
// upgrades, which currently passes the entire chain state as an in-memory byte slice.
// https://github.com/tendermint/tendermint/issues/5184
//
// 2) io.ReadCloser streams automatically propagate IO errors, and can pass arbitrary
// errors via io.Pipe.CloseWithError().
// 2. io.ReadCloser streams automatically propagate IO errors, and can pass arbitrary
// errors via io.Pipe.CloseWithError().
type Manager struct {
store *Store
multistore types.Snapshotter
Expand Down Expand Up @@ -78,6 +78,10 @@ func NewManagerWithExtensions(store *Store, multistore types.Snapshotter, extens
}
}

func (m *Manager) SetMultiStore(s types.Snapshotter) {
m.multistore = s
}

func (m *Manager) Close() error {
return m.store.db.Close()
}
Expand Down

0 comments on commit 355f18b

Please sign in to comment.