[FLINK-38614][runtime] Defer EndOfData until final checkpoint committables are emitted#28476
Draft
MartijnVisser wants to merge 1 commit into
Draft
Conversation
Collaborator
…ables are emitted The sink CommitterOperator forwards the final checkpoint's committables to a downstream global committer on notifyCheckpointComplete, i.e. after endInput. With unaligned checkpoints these committables can land in the post-end-of-input final checkpoint, which completes after the task has already broadcast EndOfData. The global committer then finishes before receiving them and drops them, causing exactly-once data loss. Defer the downstream EndOfData broadcast for tasks whose operator chain emits records on the final checkpoint until that checkpoint completes. Generated-by: Claude Opus 4.8
40ce6f4 to
6ca2ae0
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.
What is the purpose of the change
SinkV2 jobs with a post-commit (global) committer can silently lose the final checkpoint's committables under unaligned checkpoints — an exactly-once data-loss bug. It surfaced as the intermittently failing
SinkV2ITCase.writerAndCommitterExecuteInStreamingModeWithScaling(FLINK-38614).Root cause: the
CommitterOperatorforwards the final checkpoint's committables to the downstream global committer only onnotifyCheckpointComplete, which (per FLIP-147) runs afterendInput. With unaligned checkpoints those committables can belong to the post-end-of-input final checkpoint. The task broadcastsEndOfDataright afterendInput(before that finalnotifyCheckpointComplete), so the downstream global committer finishes consuming its input before the committables arrive and silently drops them.This change defers the downstream
EndOfDatabroadcast — for tasks whose operator chain emits records on the final checkpoint — until the final checkpoint completes, so those records are delivered before the downstream finishes.Brief change log
@Internalmarker interfaceEmitsRecordsOnFinalCheckpointinorg.apache.flink.streaming.api.operators(besideBoundedOneInput).CommitterOperatorimplements it; it returnstrueonly when it forwards downstream and a final checkpoint will be taken (streaming + checkpointing). The condition is centralized inhasFinalCheckpoint(), shared withendInput.StreamTask.endDatadefers the downstreamEndOfDatabroadcast when checkpoints-after-tasks-finished is enabled and the chain contains such an operator;StreamTask.notifyCheckpointCompleteflushes the deferred broadcast once the final checkpoint completes.StreamTaskDeferredEndOfDataTest.Notes for reviewers:
instanceof CommitterOperator: the deferral is a generic task-lifecycle concern, andStreamTaskshould not depend on the sink package.CommitterOperatoris the only in-tree implementor today.shouldDeferEndOfData()short-circuits unless checkpoints-after-finished-tasks is enabled and an operator opts in.endDataruns once per task, not a per-record path.afterInvokealready gates termination onfinalCheckpointCompletedunder the identical condition, so the deferral adds no new termination dependency. The flush is gated on the final checkpoint completing; an uncompleted/aborted checkpoint does not flush, and an early flush is deliberately avoided because it would re-introduce the loss.Verifying this change
This change added tests and can be verified as follows:
StreamTaskDeferredEndOfDataTest(new) deterministically verifies (a) the final-checkpoint record is emitted beforeEndOfDatadownstream, and (b) the deferredEndOfDatais not flushed by an uncompleted/aborted final checkpoint but is flushed (after the record) once a later one completes. Both assertions fail without the fix.StreamTaskFinalCheckpointsTest,SinkV2CommitterOperatorTest,SinkV2SinkWriterOperatorTest,CheckpointAfterAllTasksFinishedITCase, andSinkV2ITCaseremain green.EndOfData).This change affects checkpoint/end-of-input coordination in
StreamTask(FLIP-147), so specialist review from a checkpointing/runtime maintainer is requested.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 4.8