test: close duplicateDB when meet error halfway (#46685)

close pingcap/tidb#46682
This commit is contained in:
lance6716
2023-09-08 19:25:43 +08:00
committed by GitHub
parent 273816051d
commit 58a2dad97f

View File

@ -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 {
@ -532,7 +538,6 @@ func NewBackend(
}
}
var duplicateDB *pebble.DB
if config.DupeDetectEnabled {
duplicateDB, err = openDuplicateDB(config.LocalStoreDir)
if err != nil {