You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "jerrypeng (via GitHub)" <gi...@apache.org> on 2026/07/14 22:30:01 UTC

[PR] [WIP][SPARK-XXXXX][SS] Support async progress tracking for Real-Time Mode [spark]

jerrypeng opened a new pull request, #57259:
URL: https://github.com/apache/spark/pull/57259

   ### What changes were proposed in this pull request?
   
   Enable Async Progress Tracking (APT) for stateless Real-Time Mode (RTM) streaming queries. Previously the combination was explicitly rejected with `STREAMING_REAL_TIME_MODE.ASYNC_PROGRESS_TRACKING_NOT_SUPPORTED`.
   
   - `StreamingQueryManager`: remove the RTM+APT rejection guard; enable APT by default for stateless RTM queries (gated by a new internal conf, with the `asyncProgressTrackingEnabled` writer option still taking precedence).
   - `SQLConf`: add `spark.sql.streaming.realTimeMode.asyncProgressTrackingByDefault.enabled`.
   - `MicroBatchExecution`: extract the inline RTM end-of-batch offset handling into `populateBatchOffsetsForRTM` and `signalProcessAllAvailableIfRealTimeMode` so the APT subclass can reuse it (behavior-preserving refactor).
   - `AsyncProgressTrackingMicroBatchExecution`: RTM-aware async offset/commit log writes, with fail-fast error propagation for async write failures.
   - `StreamingErrors` + `error-conditions.json`: add the log-write-failure and RTM checkpoint-interval error conditions.
   - Docs: RTM page no longer states APT is unsupported.
   
   ### Why are the changes needed?
   
   APT lets RTM stateless queries checkpoint offset/commit logs asynchronously, keeping checkpoint I/O off the critical path for low-latency processing.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Stateless Real-Time Mode queries now use async progress tracking by default, and `asyncProgressTrackingEnabled=true` is now accepted (rather than rejected) in RTM.
   
   ### How was this patch tested?
   
   New `AsyncProgressTrackingRealTimeModeSuite` (happy path, default-on enablement, user-override precedence, stateful exclusion, recovery, back-pressure, and fail-fast on both commit-log and offset-log write failures). Existing APT and RTM suites and `SparkThrowableSuite` pass.
   
   Co-authored-by: Isaac
   
   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as new features, bug fixes, or other behavior changes. Documentation-only updates are not considered user-facing changes.
   
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "jerrypeng (via GitHub)" <gi...@apache.org>.
jerrypeng commented on PR #57259:
URL: https://github.com/apache/spark/pull/57259#issuecomment-5025032809

   > Btw, could you please update the section of Was this patch authored or co-authored using generative AI tooling? to "model name and version"?
   
   Done


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "jerrypeng (via GitHub)" <gi...@apache.org>.
jerrypeng commented on code in PR #57259:
URL: https://github.com/apache/spark/pull/57259#discussion_r3616132943


##########
sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamTest.scala:
##########
@@ -712,9 +714,15 @@ trait StreamTest extends SharedSparkSession with TimeLimits {
               s"incorrect exception returned by query.exception()")
 
             val exception = currentStream.exception.get
-            verify(exception.cause.getClass === ef.causeClass,
-              "incorrect cause in exception returned by query.exception()\n" +
-                s"\tExpected: ${ef.causeClass}\n\tReturned: ${exception.cause.getClass}")
+            if (ef.typeIsSuperClass) {

Review Comment:
   Good call out.  Lets add it for consistency.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on PR #57259:
URL: https://github.com/apache/spark/pull/57259#issuecomment-5020001205

   Btw, could you please update the section of `Was this patch authored or co-authored using generative AI tooling?` to "model name and version"?


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on PR #57259:
URL: https://github.com/apache/spark/pull/57259#issuecomment-5028037379

   **Merge Summary:**
   - merged into master https://github.com/apache/spark/commit/acc92cd68f959e7f3223bba36a797069a4f216ab
   - merged into branch-4.x https://github.com/apache/spark/commit/19346b896539d15290e7c6398c9462d26e7635d9


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "jerrypeng (via GitHub)" <gi...@apache.org>.
jerrypeng commented on code in PR #57259:
URL: https://github.com/apache/spark/pull/57259#discussion_r3606833928


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -7370,6 +7394,11 @@
       "Streaming real-time mode has the following limitation:"
     ],
     "subClass" : {
+      "ASYNC_PROGRESS_TRACKING_CHECKPOINTING_INTERVAL_NON_ZERO" : {
+        "message" : [
+          "The checkpointing interval for async progress tracking must be set to 0, which means each progress update is checkpointed. Set option asyncProgressTrackingCheckpointIntervalMs to 0 in DataStreamWriter options and retry your query."
+        ]
+      },
       "ASYNC_PROGRESS_TRACKING_NOT_SUPPORTED" : {

Review Comment:
   Lets remove it!



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "shrirangmhalgi (via GitHub)" <gi...@apache.org>.
shrirangmhalgi commented on code in PR #57259:
URL: https://github.com/apache/spark/pull/57259#discussion_r3600929106


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -7370,6 +7394,11 @@
       "Streaming real-time mode has the following limitation:"
     ],
     "subClass" : {
+      "ASYNC_PROGRESS_TRACKING_CHECKPOINTING_INTERVAL_NON_ZERO" : {
+        "message" : [
+          "The checkpointing interval for async progress tracking must be set to 0, which means each progress update is checkpointed. Set option asyncProgressTrackingCheckpointIntervalMs to 0 in DataStreamWriter options and retry your query."
+        ]
+      },
       "ASYNC_PROGRESS_TRACKING_NOT_SUPPORTED" : {

Review Comment:
   nit: `STREAMING_REAL_TIME_MODE.ASYNC_PROGRESS_TRACKING_NOT_SUPPORTED` is now dead - the only thrower (StreamingQueryManager) is removed by this PR, and the test asserting on it is also removed from `StreamRealTimeModeSuite`. Should the error condition entry itself be removed too?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "jerrypeng (via GitHub)" <gi...@apache.org>.
jerrypeng commented on code in PR #57259:
URL: https://github.com/apache/spark/pull/57259#discussion_r3606874004


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/runtime/AsyncProgressTrackingMicroBatchExecution.scala:
##########
@@ -61,8 +62,15 @@ class AsyncProgressTrackingMicroBatchExecution(
   // writes to execute in order in a serialized fashion
   protected val asyncWritesExecutorService
   = ThreadUtils.newDaemonSingleThreadExecutorWithRejectedExecutionHandler(
-    "async-log-write",
-    2, // one for offset commit and one for completion commit
+    AsyncProgressTrackingMicroBatchExecution.ASYNC_LOG_WRITE_THREAD_NAME,
+    if (trigger.isInstanceOf[RealTimeTrigger]) {
+      // Two tasks can be buffered, one in the active task and one in the queue.

Review Comment:
   Will reword to make clear the 1 is the queue capacity and the "two" refers to total in-flight (1 active + 1 queued), while keeping the note about why we bound it.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on code in PR #57259:
URL: https://github.com/apache/spark/pull/57259#discussion_r3612685332


##########
sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamTest.scala:
##########
@@ -712,9 +714,15 @@ trait StreamTest extends SharedSparkSession with TimeLimits {
               s"incorrect exception returned by query.exception()")
 
             val exception = currentStream.exception.get
-            verify(exception.cause.getClass === ef.causeClass,
-              "incorrect cause in exception returned by query.exception()\n" +
-                s"\tExpected: ${ef.causeClass}\n\tReturned: ${exception.cause.getClass}")
+            if (ef.typeIsSuperClass) {

Review Comment:
   nit: If this is needed, is there a chance we need this in L730 as well? I know there is no caller in this PR, but just think out loud while we are here, since we got the parameter but have a path which do not respect the parameter.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR closed pull request #57259: [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode
URL: https://github.com/apache/spark/pull/57259


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "shrirangmhalgi (via GitHub)" <gi...@apache.org>.
shrirangmhalgi commented on code in PR #57259:
URL: https://github.com/apache/spark/pull/57259#discussion_r3600940103


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/runtime/AsyncProgressTrackingMicroBatchExecution.scala:
##########
@@ -61,8 +62,15 @@ class AsyncProgressTrackingMicroBatchExecution(
   // writes to execute in order in a serialized fashion
   protected val asyncWritesExecutorService
   = ThreadUtils.newDaemonSingleThreadExecutorWithRejectedExecutionHandler(
-    "async-log-write",
-    2, // one for offset commit and one for completion commit
+    AsyncProgressTrackingMicroBatchExecution.ASYNC_LOG_WRITE_THREAD_NAME,
+    if (trigger.isInstanceOf[RealTimeTrigger]) {
+      // Two tasks can be buffered, one in the active task and one in the queue.

Review Comment:
   nit: comment says "Two tasks can be buffered" but the parameter value is `1` (the queue capacity). The comment is describing system capacity (1 active + 1 queued = 2 in-flight), not the parameter. Slightly confusing - consider: `1 // queue capacity; with the active task, at most 2 writes in flight`
   



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on PR #57259:
URL: https://github.com/apache/spark/pull/57259#issuecomment-5028027184

   Thanks! Merging to master/4.x.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58131][SS][RTM] Support async progress tracking for Real-Time Mode [spark]

Posted by "jerrypeng (via GitHub)" <gi...@apache.org>.
jerrypeng commented on PR #57259:
URL: https://github.com/apache/spark/pull/57259#issuecomment-5010038200

   @shrirangmhalgi thanks for the review.  I have addressed your comments.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org