feat: add Kafka exactly-once consume-process-produce#134
Merged
Conversation
Flesh out the source Transactional capability into a working EOS path so a consume-process-produce cycle commits the produced records and the consumed offset atomically on Kafka. Core seam (source): Transactional.Begin now fences a consumed Message together with the records produced through a new backend-neutral Tx handle (Tx.Produce, ProducedRecord), so emit and ack are one atomic unit. No vendor type crosses the seam. source/kafka: WithTransactional(id) builds a GroupTransactSession with read-committed isolation and no auto-commit; Begin produces through the session, marks the consumed offset on success only, and ends with TryCommit/TryAbort. A narrow transactor seam keeps the begin/produce/end choreography unit-testable with a fake session. source/statemachine: DriveTx runs Fire + emit-as-produce + persist + offset commit inside one transaction via a TxSink, returning Manual so the engine does not re-settle; Drive remains the at-least-once fallback. A broker abort after a durable save is covered by state-version dedup. Tests: fake transact-session unit tests asserting begin/produce/commit/abort ordering and the bridge's transactional path; an integration test (RedPanda) doing a consume-produce EOS round-trip and asserting no duplicate output across an aborted transaction. Docs: an Exactly-once (Kafka EOS) section in source adapters and with-state, plus changelog notes. Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
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.
What this change does
Fleshes out the
sourceTransactionalcapability into a working Kafka exactly-once path (one of the four roadmap items from #131), so a consume-process-produce cycle commits the produced records and the consumed offset as one atomic unit.source):Transactional.Beginnow fences a consumedMessagetogether with records produced through a new backend-neutralTxhandle (Tx.Produce,ProducedRecord) — emit and ack become one atomic unit. No vendor type crosses the seam.source/kafka:WithTransactional(id)builds aGroupTransactSession(read-committed, no auto-commit);Beginproduces through the session, marks the consumed offset on success only, and ends withTryCommit/TryAbort. A narrow transactor seam keeps the begin/produce/end choreography unit-testable with a fake session.source/statemachine:DriveTxruns Fire + emit-as-produce + persist + offset-commit inside one transaction via aTxSink, returningManualso the engine does not re-settle.Driveremains the at-least-once fallback; a broker abort after a durable save is covered by state-version dedup.Why
Exactly-once consume-transition-emit is the headline guarantee of the
source/statemachinebridge. On Kafka that requires the transactional producer fencing the offset commit, which only the adapter can wire — so the core seam stays vendor-neutral and the Kafka adapter owns the choreography. The capability is additive: existing at-least-once consumers are untouched.Relates to: follows up the source Tier-1 PR (#131).
Checklist
git commit -s) per the DCOtype: subject)mage checkruns in CI across the workspace and the GOWORK=off source destinations