Repository navigation
[ISSUE #141] fix(legacy): stop the legacy source rewinding and surface legacy sink async failures - #148
Merged
Conversation
…surface legacy sink async failures The legacy source read its next position back from DefaultLitePullConsumer#committed after every poll. Auto-commit is off by default, so the broker-side commit never advances and every poll round re-seeked to the same offset and re-emitted the whole topic: an acceptance run on a commercial 5.5.1 cluster turned 101 source messages into 120065 sink messages (118560 duplicates) while the job stayed RUNNING with no restarts and no errors. Book the position from the messages a poll drains instead, per queue, because poll serves every assigned queue. Seeking, polling and booking now happen under one lock. poll drains all assigned queues, so a seek issued by one queue thread after another thread's poll rewound that queue and duplicated the messages it had just drained; the first version of this fix still showed 30 duplicates for that reason. initOffsets also stored committed() verbatim, which is -1 for a group that has never committed. The EARLIEST and LATEST branches had no fallback for it (only GROUP_OFFSETS did), so the first seek failed with "Seek offset illegal" and the source gave up, finishing the job having read nothing. Fall back to the position the preceding seek left in the local offset store. The legacy sink parked the first async send failure and rethrew it from finish(), and invoke() checks it too, but a burst of failures followed by an idle stream never reaches another invoke, and snapshotState did not check at all: checkpoints completed over the lost records and stop-with-savepoint succeeded. Check the parked failure in snapshotState as well, so a checkpoint cannot commit a loss. Verified on a commercial 5.5.1 cluster with Flink 1.20.3: legacy source + legacy sink, 100 messages, duplicates 118560 -> 0; legacy sink in pure async mode with every send rejected, task failures 0 -> 3 with the IOException raised from snapshotState, i.e. the loss is now loud instead of silent.
This was referenced Nov 2, 2026
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.
Motivation
Two silent-wrong-data defects in the legacy connector, both found by an acceptance run against a commercial 5.5.1 cluster (Flink 1.20.3, Application mode) and both in the family ISSUE #141 tracks: the job stays RUNNING, checkpoints succeed, nothing is logged, and the data is wrong.
1. The legacy source re-emits its whole topic, forever.
pollAndEmitread the next position back fromDefaultLitePullConsumer#committedafter every poll. Auto-commit is off by default, so the broker-side commit never advances and every round re-seeked to the same offset. Measured: 101 source messages became 120065 sink messages (118560 duplicates) with the job RUNNING, zero restarts and zero errors.Two related faults fell out of fixing it:
polldrains all assigned queues, so seeking from one queue thread after another thread's poll rewound that queue and re-emitted what it had just drained. The first version of this fix still duplicated 30 messages for exactly this reason; seek + poll + booking are now atomic under the checkpoint lock.initOffsetsstoredcommitted()verbatim, which is -1 for a group that has never committed. Only theGROUP_OFFSETSbranch had a fallback for that, so withEARLIEST/LATESTthe first seek failed withSeek offset illegaland the source gave up, finishing the job having read nothing. It now falls back to the position the preceding seek left in the local offset store.2. The legacy sink checkpoints over lost records. An async send failure is parked and rethrown from
finish(), andinvoke()checks it too — but a burst of failures followed by an idle stream never reaches anotherinvoke(), andsnapshotStatedid not check at all. Measured: 101 rejected sends, 101Async send message failure!errors, 0 task failures, 12 successful checkpoints, a clean stop-with-savepoint, and 0 records in the sink topic.snapshotStatenow surfaces the parked failure, so a checkpoint cannot commit a loss.Modification
RocketMQSourceFunction: book the read position from the messages a poll drains (per queue, forward-only); make seek + poll + booking atomic; never store a negative start position.RocketMQSink: callcheckAsyncSendException()fromsnapshotState().RocketMQSourceFunctionTestgains a poll-position test (a stalecommitted()of 0 must not rewind a position of 6); newRocketMQSinkAsyncFailureTestpins thatsnapshotStatefails the checkpoint when an async send already failed.Verification
mvn -pl flink-connector-rocketmq test: 123 tests, 0 failures, 0 errors.CODE 13): task failures 0 → 3, stack topIOException: Async send message failedatRocketMQSink.checkAsyncSendException←snapshotState, i.e. the loss is now loud instead of silent.