fix(kafka-sink): return error instead of silent Ok on missing commit restore state#1099
Open
kotwal-itpro wants to merge 1 commit into
Conversation
…restore state The exactly-once Kafka sink's handle_commit path silently returned Ok(()) when producer_to_complete was None — a state that indicates the operator restarted between handle_checkpoint and handle_commit and lost the in-memory reference to the transactional producer. In that state the pending Kafka transaction may have already committed on the broker, aborted, or still be open; the sink has no way to tell without querying transaction state, and checkpoint restore during the two-phase-commit window is not yet implemented (as the pre-existing error message on that branch noted). Silently returning Ok(()) told the checkpoint coordinator the commit succeeded when its outcome was in fact unknown, breaking the exactly-once contract. Return a DataflowError instead so the pipeline fails loudly rather than proceeding with unknown consistency. Adds a unit test covering the None-producer path that does not require a live Kafka broker.
9562721 to
f7ffbc7
Compare
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.
Problem
The exactly-once Kafka sink's
handle_commitpath silently returnedOk(())whenproducer_to_completewasNone— a state that indicates the operator restarted betweenhandle_checkpointandhandle_commitand lost the in-memory reference to the transactional producer. In that state the pending Kafka transaction may have already committed on the broker, aborted, or still be open; the sink has no way to tell without querying transaction state, and checkpoint restore during the two-phase-commit window is not yet implemented (as the pre-existingerror!("... Restoring from commit phase not yet implemented")on that branch already noted).Silently returning
Ok(())told the checkpoint coordinator the commit succeeded when its outcome was in fact unknown, breaking the exactly-once contract.Fix
Return a
DataflowError::ConnectorError { domain: Internal, retry: NoRetry, ... }on that branch so the pipeline fails loudly rather than proceeding with unknown consistency. Uses the existingconnector_err!macro.Test
Adds
test_handle_commit_returns_error_when_producer_state_missinginkafka/sink/test.rsthat constructs aKafkaSinkFuncinExactlyOnce { producer_to_complete: None }mode and assertshandle_commitreturnsErr. The test does not require a live Kafka broker because theNonebranch returns before any producer call.Existing tests unchanged.