Skip to content

Commit

Permalink
test: close duplicateDB when meet error halfway (#46685)
Browse files Browse the repository at this point in the history
close #46682
  • Loading branch information
lance6716 authored Sep 8, 2023
1 parent 2738160 commit 58a2dad
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions br/pkg/lightning/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,13 @@ func NewBackend(
tls *common.TLS,
config BackendConfig,
regionSizeGetter TableRegionSizeGetter,
) (*Backend, error) {
) (b *Backend, err error) {
var duplicateDB *pebble.DB
defer func() {
if err != nil && duplicateDB != nil {
_ = duplicateDB.Close()
}
}()
config.adjust()
pdCtl, err := pdutil.NewPdController(ctx, config.PDAddr, tls.TLSConfig(), tls.ToPDSecurityOption())
if err != nil {
Expand All @@ -532,7 +538,6 @@ func NewBackend(
}
}

var duplicateDB *pebble.DB
if config.DupeDetectEnabled {
duplicateDB, err = openDuplicateDB(config.LocalStoreDir)
if err != nil {
Expand Down

0 comments on commit 58a2dad

Please sign in to comment.