Skip to content

Commit

Permalink
Merge pull request #18855 from ghouscht/backport-defrag-close-temp-3.4
Browse files Browse the repository at this point in the history
[3.4] fix(defrag): close temp file in case of error
  • Loading branch information
ahrtr authored Nov 9, 2024
2 parents 29145e8 + d5bf838 commit c4d1505
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mvcc/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,15 @@ func (b *backend) defrag() error {
tdbp := temp.Name()
tmpdb, err := bolt.Open(tdbp, 0600, &options)
if err != nil {
temp.Close()
if rmErr := os.Remove(temp.Name()); rmErr != nil && b.lg != nil {
b.lg.Error(
"failed to remove temporary file",
zap.String("path", temp.Name()),
zap.Error(rmErr),
)
}

return err
}

Expand Down

0 comments on commit c4d1505

Please sign in to comment.