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

feat: CV Close databases opened by cosmos-sdk during BaseApp shutdown (backport #17667) #17669

Merged
merged 3 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvments

* (types/module) [#17554](https://github.com/cosmos/cosmos-sdk/pull/17554) Introduce `HasABCIGenesis` which is implemented by a module only when a validatorset update needs to be returned
* (baseapp) [#17667](https://github.com/cosmos/cosmos-sdk/pull/17667) Close databases opened by cosmos-sdk during BaseApp shutdown

### Bug Fixes

Expand Down
24 changes: 23 additions & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1066,5 +1066,27 @@

// Close is called in start cmd to gracefully cleanup resources.
func (app *BaseApp) Close() error {
return nil
var errs []error

// Close app.db (opened by cosmos-sdk/server/start.go call to openDB)
if app.db != nil {
app.logger.Info("Closing application.db")
if err := app.db.Close(); err != nil {
errs = append(errs, err)
}
}

// Close app.snapshotManager
// - opened when app chains use cosmos-sdk/server/util.go/DefaultBaseappOptions (boilerplate)
// - which calls cosmos-sdk/server/util.go/GetSnapshotStore
// - which is passed to baseapp/options.go/SetSnapshot
// - to set app.snapshotManager = snapshots.NewManager
if app.snapshotManager != nil {
app.logger.Info("Closing snapshots/metadata.db")
if err := app.snapshotManager.Close(); err != nil {
errs = append(errs, err)
}
}

return errors.Join(errs...)

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / dependency-review

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (00)

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (00)

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (00)

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (00)

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (00)

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (00)

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (01)

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (01)

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (01)

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (01)

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (02)

undefined: errors.Join

Check failure on line 1091 in baseapp/baseapp.go

View workflow job for this annotation

GitHub Actions / tests (03)

undefined: errors.Join
}
Loading