Merge pull request #16120 from Tachone/shitao.lst/fix_db_close

etcdutl: fix db double closed
This commit is contained in:
Benjamin Wang 2023-07-06 20:03:51 +01:00 committed by GitHub
commit 4364e7581b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -422,13 +422,8 @@ func (s *v3Manager) copyAndVerifyDB() error {
if dberr != nil {
return dberr
}
dbClosed := false
defer func() {
if !dbClosed {
db.Close()
dbClosed = true
}
}()
defer db.Close()
if _, err := io.Copy(db, srcf); err != nil {
return err
}
@ -465,7 +460,7 @@ func (s *v3Manager) copyAndVerifyDB() error {
}
// db hash is OK, can now modify DB so it can be part of a new cluster
db.Close()
return nil
}