spark-test commented on code in PR #60700:
URL: https://github.com/apache/spark/pull/60700#discussion_r4623602110


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/runtime/IncrementalExecution.scala:
##########
@@ -600,11 +600,13 @@ class IncrementalExecution(
         // and silently stop state eviction. Fall back to None (full scan) in 
that mode, as we
         // don't expect the legacy mode to be used by many users.
         //
-        // The prevOffsetSeqMetadata.isDefined check guards against the first 
batch, where
+        // The isFirstBatch check guards against the first batch of each run. 
In batch 0,
         // watermark propagation yields Some(0) for late events even though no 
state has been
-        // evicted yet, which would incorrectly skip entries at timestamp 0.
+        // evicted yet, which would incorrectly skip entries at timestamp 0. 
After a restart, the
+        // previous run, such as an older version, can have evicted less state 
than this run's
+        // cutoffs imply, so the rows it left would be skipped.
         val prevBatchLateEventsWm =
-          if (prevOffsetSeqMetadata.isDefined && 
allowMultipleStatefulOperators) {
+          if (!isFirstBatch && allowMultipleStatefulOperators) {

Review Comment:
   **Nit (P3):** This guard now checks isFirstBatch, but two comments in 
StreamingJoinV4Suite.scala still explain its regression tests by the check it 
replaced. StreamingJoinV4Suite.scala:413-415 says the bound is withheld because 
"in the first batch prevOffsetSeqMetadata is None", and 
StreamingJoinV4Suite.scala:525 says legacy mode keeps it None "even though 
prevOffsetSeqMetadata is now defined". Both matched the guard on the base 
branch. After this change they describe a check the guard no longer makes, and 
they mislead in exactly the case this PR fixes: the first batch of a restarted 
run has prevOffsetSeqMetadata defined (MicroBatchExecution.scala:1355) and 
still gets no bound because isFirstBatch is true 
(MicroBatchExecution.scala:1358), so a maintainer reading those comments is 
pointed at the old check. Test and runtime behavior are unchanged. Rewording 
both comments to name isFirstBatch fixes it, for example "even though this is 
no longer the first batch of the run" at Streamin
 gJoinV4Suite.scala:525.
   
   **Verification:**
   - **Inspection:** Check that no comment in StreamingJoinV4Suite.scala still 
describes the IncrementalExecution lower-bound guard as a check of 
prevOffsetSeqMetadata, that the two reworded comments name the isFirstBatch 
check performed at IncrementalExecution.scala line 609, and that the edit 
touches only comment lines.



-- 
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]

Reply via email to