Skip to content

Commit

Permalink
etcdutl: fix db double closed
Browse files Browse the repository at this point in the history
Signed-off-by: shitao.lst <acm_tach@163.com>
  • Loading branch information
Tachone committed Jun 28, 2023
1 parent bda68d8 commit 7bd77c2
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 @@ -340,13 +340,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 @@ -383,7 +378,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 7bd77c2

Please sign in to comment.