Skip to content

Commit

Permalink
ffldb: close block files before deleting them
Browse files Browse the repository at this point in the history
The block files may be open when deleteFile is called.  This resulted in
files not being deleted and erroring out on windows.  Properly closing
the files closing the files avoids this error.
  • Loading branch information
kcalvinalvin committed Jul 1, 2024
1 parent 8ed8ef1 commit c9fae1a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions database/ffldb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,9 @@ func (tx *transaction) writePendingAndCommit() error {
// We do this first before doing any of the writes as we can't undo
// deletions of files.
for _, fileNum := range tx.pendingDelFileNums {
// Make sure the file is closed before attempting to delete it.
tx.db.store.closeFile(fileNum)

err := tx.db.store.deleteFileFunc(fileNum)
if err != nil {
// Nothing we can do if we fail to delete blocks besides
Expand Down

0 comments on commit c9fae1a

Please sign in to comment.