Repository navigation
[ISSUE #153] fix(remoting): send asynchronously with bounded in-flight capacity and retry transient seek failures - #154
Merged
Conversation
…d retry transient seek failures - Replace the calling-thread synchronous send with a true async SendCallback path on a bounded sender executor; fail the future on non-SEND_OK results and synchronous submission errors, and shut the executor down on close. - Enforce send.pending.max with a semaphore, return the permit when the async-failure check throws, keep async failures sticky, bound flush by producer send.timeout, and drain pending sends before closing the writer. - Expose sendCompletionRt and sendPendingRecords writer gauges. - Retry source seek up to two times with 100 ms backoff on connect, send-request and timeout transport failures; propagate other failures and interrupts immediately. - Cover callback completion, permit accounting, flush/close semantics and seek retry boundaries with unit tests.
This was referenced Nov 2, 2026
lizhimins
added a commit
that referenced
this pull request
Nov 2, 2026
* [ISSUE #155] refactor: migrate to the new Source/Sink API only Flink 2.x removed SourceFunction, SinkFunction, TwoPhaseCommittingSink, TableSchema and the ConfigOption-typed Configuration accessors. The connector still ships the legacy implementations next to the FLIP-27 / sink2 ones, so it cannot compile against 2.x and every fix lands twice. Following apache/flink-connector-kafka (new API only, zero legacy, version differences isolated in branches), migrate the shared codebase to the new API while staying on Flink 1.20.3 / Java 11: - Delete the legacy source/sink paths and their tests; the FLIP-27 Source and the sink2 Sink + SupportsCommitter become the only runtime paths. The SQL factory keeps accepting the existing DDL options but resolves them to the new implementations. - TableSchema / SchemaValidator -> ResolvedSchema; Configuration getXxx(ConfigOption) / setXxx -> get / set. - Sink.InitContext and TypeInformation.createSerializer(ExecutionConfig) are still abstract in 1.20; implement the deprecated overloads as delegations. The 1.20 runtime calls the WriterInitContext / SerializerConfig overloads, so the main code path is already the 2.x one. - The async-send bounding and seek-retry behavior of #154 is preserved. Semantics are unchanged: at-least-once / exactly-once guarantees, offset management from Flink state, checkpoint-aligned transaction commits and the #154 permit accounting all stay as they are; this is an API migration, not a behavior change. Verified: mvn clean install green on JDK 17 targeting Java 11 (remoting 146 / grpc 80 unit tests, checkstyle and spotless clean), both SQL fat-jars produced. This is the branch point for the 1.x maintenance line (#155): a follow-up commit switches main to Flink 2.2.1 / Java 17 by flipping flink.version and dropping the deprecated-overload bridges above. * [ISSUE #155] style: apply spotless formatting under JDK 11 The JDK 17 leg of the build silently skips spotless ("Spotless check skipped"), so the four files reformatted here only surfaced on the JDK 11 leg, which is the one that actually runs the formatter. Wrap them to the 100-column google-java-format output; no behavioural change.
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
Fixes the two defects reported in #153, both observed during a Kubernetes acceptance run (Flink 1.20.3, RocketMQ 5.5.1 direct-connect and a proxy-fronted commercial distribution, 4 KiB messages, TM 1 / 2 / 4 / 8):
The sink's "async" send is synchronous on the task thread.
InnerProducerImpl.send()usedCompletableFuture.supplyAsync(..., Runnable::run), which executes the blockingproducer.send()on the calling thread and returns an already-completed future. Single-slot throughput was capped at1 / send RTT(Proxy Sink TM8: 16,397 rec/s at 7.9% TM CPU, zero CFS throttling),send.pending.maxcould never accumulate in-flight sends,flush()never waited for real acknowledgements, andclose()did not drain at all. Synchronous submission errors also leaked the semaphore permit, andcheckAsyncException()consumed the stored failure withgetAndSet(null), losing it after the first throw.Startup
seekfails the job on transient transport errors.InnerConsumerImpl.seek()wrapped everyMQClientExceptionintoFlinkRuntimeException; aRemotingSendRequestExceptionduring startup exhausted the 3-restart budget and drove the job to terminalFAILEDagainst a cluster that served traffic normally seconds later.Brief change log
InnerProducerImpl: true asyncproducer.send(message, SendCallback)on a boundedasyncSenderExecutor(executor.numthreads,send.pending.maxqueue bound); the future completes only from the callback and fails on non-SEND_OKresults and synchronous submission errors (restoring the interrupt flag forInterruptedException); the executor is shut down with asendMsgTimeoutbound on close.RocketMQWriter: release the permit when the async-failure check throws after acquisition; keep async failures sticky (get()instead ofgetAndSet(null)); boundflush()byproducer.send.timeoutand fail with a recorded timeout instead of spinning forever;close()flushes pending sends before closing the producer; validatesend.pending.max/send.timeoutare positive.RocketMQWritermetrics:sendPendingRecordsgauge and asendCompletionRtgauge exposing a fixed 1024-bucket (250 μs) completion-time histogram plus count / total-nanos / failed counters, used to measure send completion RT (avg / p99) in the acceptance runs.InnerConsumerImpl.seek(): retry up to 2 times with 100 ms backoff only when the direct cause isRemotingConnectException,RemotingSendRequestExceptionorRemotingTimeoutException; other failures propagate immediately and interruption is preserved.InitContext.metricGroup()because the constructor registers gauges.Verifications
spotless:checkgreen; the five affected test classes pass (27 tests, 0 failures); the full remoting regression was run on the identical code during the acceptance campaign (155 tests, 0 failures, 6 pre-existing skips).RemotingSendRequestExceptionexhausted the restart budget → terminal FAILED).Closes #153