Skip to content

Commit

Permalink
Merge pull request #16120 from Tachone/shitao.lst/fix_db_close
Browse files Browse the repository at this point in the history
etcdutl: fix db double closed
  • Loading branch information
ahrtr committed Jul 6, 2023
2 parents f4444e8 + 7bd77c2 commit 4364e75
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions etcdutl/snapshot/v3_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 4364e75

Please sign in to comment.