[GSoC 2026] Kafka Streams runner: bound a bundle by element count - #39578
Open
junaiddshaukat wants to merge 1 commit into
Open
Conversation
A bundle stayed open until the next watermark, so on a stream that produces steadily it grew without limit and nothing it had already processed was emitted until a watermark happened to arrive. maxBundleSize was declared as a pipeline option but nothing read it. The stage now counts the elements fed to the open bundle and closes it once that many have gone in, and closing a bundle asks Kafka Streams to commit, so the elements a bundle consumed and the records it produced are committed together and a restart replays either all of the bundle or none of it. That aligns commits to bundle boundaries; it does not stop Kafka Streams from committing on its own interval part-way through a bundle, which would need a pre-commit hook, and the class documents that. maxBundleTimeMs is still not applied. Closing a bundle from a wall-clock punctuator made the pipeline with two chained GroupByKeys across four partitions emit its group repeatedly against a real broker, with the count still climbing after the input stopped. The same bundles closed from the record path are fine, and requesting the commit is not the cause — the duplication happens with the commit request removed. Rather than ship behaviour whose failure mode is not understood, the option documents that it has no effect yet. BundleBoundaryTest covers the size bound and the case of a bound the input never reaches. MetricsAcrossBundlesTest pins down that splitting the same input across many bundles does not change a user counter, since the runner folds each bundle's metrics by adding them.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Contributor
|
Assigning reviewers: R: @jrmccluskey added as fallback since no labels match configuration Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
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.
Summary
Part of #18479.
A bundle stayed open until the next watermark arrived. On a stream that produces steadily that means it grows without limit, and on one where watermarks are sparse the elements already fed to it are not emitted for as long as the gap lasts.
maxBundleSizewas declared as a pipeline option but nothing read it.The stage now counts the elements fed to the open bundle and closes it once the bound is reached.
Commits at bundle boundaries
Closing a bundle asks Kafka Streams to commit, so the elements a bundle consumed and the records it produced are committed together: a restart replays either the whole bundle or none of it.
Worth being precise about what that does and does not give. It aligns commits to bundle boundaries; it does not prevent Kafka Streams from committing on its own interval part-way through a bundle. Ruling that out would mean closing the bundle from a pre-commit hook, so that the bundle is always finished before offsets are committed. The class documents this.
maxBundleTimeMsis still not appliedThe natural implementation — close the bundle from a wall-clock punctuator once it has been open longer than the bound — does not work against a real broker, so it is not in this PR and the option documents that it currently has no effect.
With the punctuator in, the integration test that runs two chained GroupByKeys across four partitions emits its single group about six times, and the count keeps climbing after the input has stopped. Without it, the count is exactly one.
What that leaves out:
MetricsAcrossBundlesTestsplits the same input across many bundles and the counter is unchanged, so per-bundle reports are per-bundle.ProcessorContext.commit(). With the punctuator disabled but the commit still requested on every close, the test passes. With the punctuator enabled but the commit request removed from it, the duplication still happens.So it appears to be closing a Fn-API bundle from a punctuator rather than from record processing, and I would rather leave a documented gap than ship behaviour whose failure mode I cannot explain. A pre-commit hook — closing the bundle from a state store's
flush()— looks like the shape that would fix both this and the mid-bundle commit noted above, and I would like to agree the approach before implementing it.Testing
BundleBoundaryTest— a bound the input passes several times over produces several bundles; a bound the input never reaches leaves a single one. The elements have to arrive as separate records for the bound to count them, so the pipelines read from aCreaterather than fanning out inside one stage, which fusion would collapse into a single input.MetricsAcrossBundlesTest— a user counter is unchanged when the same input is split across many bundles.