fix(rest): release fetched FileScanTask state to prevent unbounded memory growth - #17429
Open
Solaris-star wants to merge 1 commit into
Open
fix(rest): release fetched FileScanTask state to prevent unbounded memory growth#17429Solaris-star wants to merge 1 commit into
Solaris-star wants to merge 1 commit into
Conversation
…mory growth The reference REST server-side scan planning implementation retains all planned FileScanTask objects in the singleton InMemoryPlanningState even after clients have successfully fetched every plan task. Neither fileScanTasksForPlanTask nor nextPlanTask removes the fetched entries, and the state is only released via cancelPlan. Per the REST Catalog OpenAPI spec, cancellation is not required after all plan tasks have been fetched, so a successful fetch lifecycle must release state without an explicit cancel request (apache#17427). Add releasePlanTask() to remove a single fetched plan task's FileScanTask list and next-task link, and releaseAsyncPlanForTask() to remove the async planning state when the last plan task in a chain is fetched. Call both from CatalogHandlers.fetchScanTasks after building the response. Adds TestInMemoryPlanningState with unit tests covering: - releasePlanTask removes both file scan tasks and next-task link - releaseAsyncPlanForTask removes async planning state - malformed keys are handled gracefully - releasing unknown keys is a no-op Note: could not run the full Gradle test suite locally (partial clone conflicts with the multi-module build), but the changes are minimal Map.remove() calls following existing patterns in the codebase.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #17427
The reference REST server-side scan planning implementation retains all planned
FileScanTaskobjects in the singletonInMemoryPlanningStateeven after clients have successfully fetched every plan task. NeitherfileScanTasksForPlanTasknornextPlanTaskremoves the fetched entries, and the state is only released viacancelPlan. Per the REST Catalog OpenAPI spec, cancellation is not required after all plan tasks have been fetched, so a successful fetch lifecycle must release state without an explicit cancel request.Fix
Add two methods to
InMemoryPlanningState:releasePlanTask(planTaskKey)— removes a single fetched plan task'sFileScanTasklist and next-task linkreleaseAsyncPlanForTask(planTaskKey)— removes the async planning state when the last plan task in a chain is fetched (extracts the planId from the key format{planId}-{tableId}-{sequence})Call both from
CatalogHandlers.fetchScanTasksafter building the response:Tests
Added
TestInMemoryPlanningStatewith 4 unit tests:releasePlanTaskremoves both file scan tasks and next-task linkreleaseAsyncPlanForTaskremoves async planning stateNote: I could not run the full Gradle test suite locally (partial clone conflicts with the multi-module build), but the changes are minimal
Map.remove()calls following existing patterns in the codebase. CI should validate.