Skip to content

Commit

Permalink
fix(defrag): close temp file in case of error
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Gosteli <thomas.gosteli@protonmail.ch>
  • Loading branch information
ghouscht committed Nov 8, 2024
1 parent d770310 commit b2ba488
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/mvcc/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,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 b2ba488

Please sign in to comment.