Skip to content

[core] Release lookup merge spills when closing sort readers - #10977

Draft
discivigour wants to merge 1 commit into
apache:masterfrom
discivigour:codex/fix-sort-merge-reader-spill-cleanup
Draft

discivigour wants to merge 1 commit into
apache:masterfrom
discivigour:codex/fix-sort-merge-reader-spill-cleanup

Conversation

@discivigour

Copy link
Copy Markdown
Contributor

Purpose

A lookup merge can spill records for the current key to local disk. Moving to the next key resets the merge state and releases those files. If the reader closes while processing a key, or immediately after it returns the last key, the spill files can survive until the IO manager shuts down.

Reset the merge function wrapper when closing both the loser-tree and min-heap readers. If closing an input fails, still attempt the reset and preserve the input exception, with any reset failure attached as a suppressed exception.

This fix was split out of #10867 because existing lookup merge readers can also leave spill files behind.

Tests

SortMergeReaderCleanupTest reproduces the bug with both sort engines. It forces a real spill, closes the reader while the IO manager is still open, and verifies that the files have been removed and the returned value remains readable. A second case checks the exception and cleanup behavior when closing the input fails. All four parameterized cases failed before the fix and passed with it.

Reset the merge wrapper when either sort reader closes so the last key releases its spill files. Preserve input close failures when resetting the wrapper also fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant