Skip to content

Commit

Permalink
Merge pull request etcd-io#16201 from Tachone/release-3.5
Browse files Browse the repository at this point in the history
[Backport 3.5] etcdutl: fix db double closed
  • Loading branch information
ahrtr authored Jul 10, 2023
2 parents e5bd8f4 + 2921992 commit d4f779a
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 @@ -415,13 +415,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 @@ -458,7 +453,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 d4f779a

Please sign in to comment.