Skip to content

Commit 39a6fd8

Browse files
authored
Merge pull request #595 from IntersectMBO/dcoutts/merging-run-finalise-order
Fix errors on table close with ongoing merges
2 parents f4a3bb5 + c6892f1 commit 39a6fd8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Database/LSMTree/Internal/MergingRun.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,13 @@ unsafeNew mergeNumRuns mergeNumEntries knownCompleted state = do
218218
CompletedMerge r ->
219219
releaseRef r
220220
OngoingMerge rs m -> do
221-
V.forM_ rs releaseRef
221+
-- The RunReaders in the Merge keep their own file handles to the
222+
-- run kopsFile open. We must close these handles *before* we release
223+
-- the runs themselves, which will close and delete the files.
224+
-- Otherwise we would be removing files that still have open handles
225+
-- (which does not work on Windows, and is caught by the MockFS).
222226
Merge.abort m
227+
V.forM_ rs releaseRef
223228

224229
-- | Create references to the runs that should be queried for lookups.
225230
-- In particular, if the merge is not complete, these are the input runs.

0 commit comments

Comments
 (0)