Repository navigation
Conversation
|
R: @Abacn |
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
13a3fbb to
82457e3
Compare
| TupleTag<OutputT> mainOutputTag = transform.getMainOutputTag(); | ||
| PCollection<OutputT> output = cxt.getOutput(mainOutputTag); | ||
| Coder<OutputT> outputCoder = output.getCoder(); | ||
| Map<TupleTag<?>, PCollection<?>> outputs = |
There was a problem hiding this comment.
(from gemini) Unconsumed mainTag with a consumed additionalTag spawns a redundant streaming query:
- ParDoTranslatorBatch.skipUnconsumedOutputs always retains mainTag even when cxt.isLeaf(mainOutput) is true.
- If a pipeline consumes only an additionalTag and ignores mainTag, outputs has size 2 ({mainTag, additionalTag}), so cxt.putDataset(mainOutput, ...) registers the unconsumed mainTag in leaves. In Spark 4 streaming, StreamingEvaluationContext
then starts an entire extra StreamingQuery (with its own duplicate transformWithState state store & checkpoint) solely to discard mainTag into noop. - This matches existing stateless ParDoTranslatorBatch behavior, so it's acceptable if intentional, but much heavier for stateful transformWithState — worth confirming or tracking alongside [Bug]: Spark 4 streaming runner runs a stateful operator once per consumer, each with its own state #41425 / [Bug]: Spark 4 streaming runner runs a shared upstream once per consuming branch #41198.
There was a problem hiding this comment.
Thanks, fixed for the stateful path. StatefulParDoStreamingTranslator now drops the main output when it is unconsumed and another output is consumed, so no extra query or state store starts. testStatefulParDoOnlyAdditionalOutputConsumed covers it, the DoFn counter was 8 before and is 4 now. The stateless path in ParDoTranslatorBatch is unchanged, it is shared with batch and builds its single output path on the main tag, and there the extra query only reruns a stateless DoFn, the same cost as #41198.
82457e3 to
28fa603
Compare
Closes #40949, part of #36841.
The streaming translator now accepts a stateful ParDo with additional outputs. It mirrors
StatefulParDoTranslatorBatch: with more than one consumed output thetransformWithStateprocessor emits wide rows with one column per tag, encoded withoneOfEncoder, and each output filters its column. The batch helpersskipUnconsumedOutputs,tagsColumnIndexandcreateEncodersare reused, so they andParDoTranslatorBatchare now@Internal public.ParDoStatefulProcessorgetssingleOutputandmultiOutputfactories, andBeamStatefulProcessoris generic on the row type with an abstract output receiver, likeStatefulDoFnGroupFunction. The single output path andGroupByKeyStatefulProcessorbehave as before.Like the stateless case in #41220, streaming datasets are not persisted, so each consumed tag runs its own
transformWithStatewith its own state. This is not new with tags, one output with two consumers already does the same on master. The copies can see a key's elements in a different order or in different micro batches, and fire timers at different points, so the tags agree only for a DoFn whose output per tag does not depend on that. A local probe with a dedup DoFn (first element per key to main, the rest to a duplicates tag) gave consistent tags in 6 of 6 runs, local mode reads deterministically. An exchange at the fan out does not help, the copies get different operator ids, so this is tracked in #41425 and is not fixed by #41198.When only additional outputs are consumed, the unconsumed main output is dropped, so it does not start a streaming query and state store of its own.
testStatefulParDoOnlyAdditionalOutputConsumedcovers it.ParDoTest$StateTests.testValueStateTaggedOutputfailed with the rejection before and passes now, its exclusion is removed. The newStatefulParDoStreamingTestcase flattens a main output from@ProcessElementand an additional output from@OnTimerinto one query and declares a third tag that is never consumed. Locally the streaming suite runs 213 tests with 0 failures, the batch Structured Streaming suites on Spark 4 and 3 and the full:runners:spark:4:testand:runners:spark:3:testpass. The trigger files run both ValidatesRunner PostCommits here.Merge order: it bumps the same Spark4 trigger line as #41256, whichever lands second rebases.