Skip to content

Spark: Stop async preload when either limit is reached - #17950

Open
iamrajatrana wants to merge 3 commits into
apache:mainfrom
iamrajatrana:spark-fix-async-preload-limits
Open

Spark: Stop async preload when either limit is reached#17950
iamrajatrana wants to merge 3 commits into
apache:mainfrom
iamrajatrana:spark-fix-async-preload-limits

Conversation

@iamrajatrana

@iamrajatrana iamrajatrana commented Sep 4, 2026

Copy link
Copy Markdown

Async micro-batch initial preload currently combines its row and file safety limits with OR, so it keeps loading snapshots until both limits are reached. With skewed snapshots, this can substantially over-buffer files or rows during catch-up.

This changes the condition to AND so preload stops when either configured safety limit is reached across Spark 3.5, 4.0, 4.1, and 4.2. It also adds direct regression coverage for both asymmetric cases.

Fixes #17951

Tests:

  • Focused TestAsyncSparkMicroBatchPlanner passes for Spark 3.5, 4.0, and 4.1
  • Spark 4.2 focused test is currently blocked before test execution by an existing main compile failure in RewriteDataFilesSparkAction and RewritePositionDeleteFilesSparkAction
  • ./gradlew -DsparkVersions=3.5,4.0,4.1,4.2 spotlessApply

AI Disclosure

  • Model: GPT-5 (Codex)
  • Platform/Tool: OpenAI Codex
  • Human Oversight: unreviewed
  • Prompt Summary: Diagnose and fix async Spark micro-batch initial preload exceeding either configured safety limit, add regression tests, and prepare the contribution.

@github-actions github-actions Bot added the spark label Sep 4, 2026
@iamrajatrana
iamrajatrana force-pushed the spark-fix-async-preload-limits branch from 7e0fd54 to 60995ac Compare September 4, 2026 20:36
@iamrajatrana
iamrajatrana marked this pull request as ready for review September 4, 2026 20:39

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense overall, and seems correct and well scoped - thank you @iamrajatrana! Please make the CI green and ping committers for further review.

Initial async micro-batch preload currently continues until both row and file limits are reached, which can retain excessive planned tasks for skewed snapshots. Stop when either limit is reached and cover both asymmetric cases.

Generated-by: Codex
Format the Spark 3.5 and 4.0 regression tests using their configured source levels so CI Spotless checks pass.

Generated-by: Codex
Keep the newly added Spark 4.2 runtime aligned with the existing Spark versions.\n\nGenerated-by: Codex
@iamrajatrana
iamrajatrana force-pushed the spark-fix-async-preload-limits branch from 60995ac to 5af974c Compare September 6, 2026 18:33
@iamrajatrana

Copy link
Copy Markdown
Author

Thanks for the review, @uros-b. The branch is now rebased onto main, and all CI checks are green. @bryanck and @RjLi13, could you please take a look when you have a chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spark: Async micro-batch preload does not stop when either limit is reached

2 participants