waterWang opened a new pull request, #17691: URL: https://github.com/apache/iceberg/pull/17691
### Problem The reference implementation of REST server-side scan planning keeps all planned `FileScanTask` objects in the singleton `InMemoryPlanningState`, even after clients have successfully fetched every plan task. As a result, repeated successful scans cause retained heap usage to grow approximately linearly with the number of planned files. The state is released only when `cancelPlanning` is called, but according to the REST Catalog OpenAPI specification, cancellation is not required after scan tasks have been fetched for every plan task. ### Fix 1. **`InMemoryPlanningState.releasePlanTask(planTaskKey)`** — removes the fetched plan task's file scan tasks and next-task link from the maps. Called after every successful fetch in `fetchScanTasks`. 2. **`InMemoryPlanningState.releaseAsyncPlanForTask(planTaskKey)`** — when the last plan task in a chain is fetched (`nextPlanTasks` is empty), also removes the async planning state for the owning plan. This mirrors the design intent of the REST Catalog API: successful fetch lifecycles must eventually release fetched task state without requiring an explicit cancellation request. ### Testing Unit tests cover: - `releasePlanTask` removes both file scan tasks and next-task links - `releaseAsyncPlanForTask` removes async planning state - Malformed keys (single hyphen, no hyphen) are safely ignored - Releasing a non-existent key is a no-op (idempotent) Closes #17427 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
