[FLINK-30068][runtime] Add configurable commit failure strategy for S… #27585
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 is the purpose of the change
When a Flink job recovers from a checkpoint/savepoint, the
CommitterOperatorreplays uncommitted transactions. If a Kafka transaction has expired or the producer ID mapping is lost (e.g.,InvalidPidMappingException), the commit fails viasignalFailedWithUnknownReason()which throws unconditionally, causing an infinite restart loop with no way to recover -- even from earlier savepoints.The
CommitRequestImplcode already had TODO comments noting: "let the user configure a strategy for failing and apply it here". This PR implements that configurability by adding aCommitFailureStrategyenum (FAIL/WARN) and a config optionsink.committer.failure-strategythat controls whether unknown commit failures throw (default, preserving current behavior) or log a warning and skip the committable, allowing recovery to proceed.Brief change log
CommitFailureStrategyenum (FAIL/WARN) inflink-corewith@PublicEvolvingannotationsink.committer.failure-strategyconfig option toSinkOptions(default:FAIL)CommitRequestImpl.signalFailedWithUnknownReason()to respect the configured strategyCommitRequestImpl.signalFailedWithKnownReason()to match interface contractcommit()method toCheckpointCommittableManagerinterface with strategy parameter (backward-compatible default method)CheckpointCommittableManagerImplto set failure strategy on requests before committingCommitterOperatorandGlobalCommitterOperatorto read and pass the strategy configVerifying this change
This change added tests and can be verified as follows:
CommitRequestImplTestwith 4 unit tests: default strategy throws, explicitFAILthrows,WARNlogs and skips,signalFailedWithKnownReasonalways discards regardless of strategyCheckpointCommittableManagerImplTest:WARNstrategy completes without throwing on unknown failures,FAILstrategy throws on unknown failuresSinkV2CommitterOperatorTest: operator-levelWARNstrategy skips failures,FAILstrategy throws, andWARNstrategy succeeds on state restore/recovery with a failing committerDoes this pull request potentially affect one of the following parts:
@Public(Evolving): yes (CommitFailureStrategyenum andSinkOptions.COMMITTER_FAILURE_STRATEGYare@PublicEvolving)WARNstrategy)Documentation
CommitFailureStrategyenum,SinkOptions.COMMITTER_FAILURE_STRATEGYconfig option description)