Repository navigation
[#36841] Spark 4 streaming: detached reader for sibling scans of one source - #40932
Merged
Merged
Conversation
Contributor
Author
|
R: @Abacn |
Contributor
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
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.
Part of #36841.
When one unbounded source PCollection feeds two branches of a streaming query, for example a Flatten of a PCollection with itself, Spark does not deduplicate streaming relations and plans one scan per branch. Both scans open a reader for the same split in the same micro batch, so they shared one
BeamReaderCacheentry: the second task either took over the reader in flight or invalidated it. With bounded input the end of stream row was then emitted again on every batch and the query never went idle. The shared entry exists since #39971, the repeated end of stream row since #40766.The second scan now gets a detached reader, restored from the start mark of the batch, never cached and writing no marks or done markers. A sibling is recognised by the query run id, so a restarted query in the same JVM still restores from the durable mark. The detached reader inherits whether the end of stream row was already emitted. A failed mark write now also drops the cached reader.
Sibling scans still read independently. A batch cut by
maxBatchDurationMilliscan differ per sibling on a live source, tracked in #40786. Bounded inputs that drain within the deadline are exact.PAssertStreamingTest.testFlattenSameSourceflattensCreatewith itself and asserts every element twice. It hangs without the fix and passed 3 of 3 runs with it. Full:runners:spark:4:testand:runners:spark:3:testpass locally.