lizhimins opened a new pull request, #154:
URL: https://github.com/apache/rocketmq-flink/pull/154

   ## 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):
   
   1. **The sink's "async" send is synchronous on the task thread.** 
`InnerProducerImpl.send()` used `CompletableFuture.supplyAsync(..., 
Runnable::run)`, which executes the blocking `producer.send()` on the calling 
thread and returns an already-completed future. Single-slot throughput was 
capped at `1 / send RTT` (Proxy Sink TM8: 16,397 rec/s at 7.9% TM CPU, zero CFS 
throttling), `send.pending.max` could never accumulate in-flight sends, 
`flush()` never waited for real acknowledgements, and `close()` did not drain 
at all. Synchronous submission errors also leaked the semaphore permit, and 
`checkAsyncException()` consumed the stored failure with `getAndSet(null)`, 
losing it after the first throw.
   
   2. **Startup `seek` fails the job on transient transport errors.** 
`InnerConsumerImpl.seek()` wrapped every `MQClientException` into 
`FlinkRuntimeException`; a `RemotingSendRequestException` during startup 
exhausted the 3-restart budget and drove the job to terminal `FAILED` against a 
cluster that served traffic normally seconds later.
   
   ## Brief change log
   
   - `InnerProducerImpl`: true async `producer.send(message, SendCallback)` on 
a bounded `asyncSenderExecutor` (`executor.num` threads, `send.pending.max` 
queue bound); the future completes only from the callback and fails on 
non-`SEND_OK` results and synchronous submission errors (restoring the 
interrupt flag for `InterruptedException`); the executor is shut down with a 
`sendMsgTimeout` bound on close.
   - `RocketMQWriter`: release the permit when the async-failure check throws 
after acquisition; keep async failures sticky (`get()` instead of 
`getAndSet(null)`); bound `flush()` by `producer.send.timeout` and fail with a 
recorded timeout instead of spinning forever; `close()` flushes pending sends 
before closing the producer; validate `send.pending.max` / `send.timeout` are 
positive.
   - `RocketMQWriter` metrics: `sendPendingRecords` gauge and a 
`sendCompletionRt` gauge 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 is `RemotingConnectException`, 
`RemotingSendRequestException` or `RemotingTimeoutException`; other failures 
propagate immediately and interruption is preserved.
   - Tests: callback-only completion (out-of-order callbacks), selector 
argument retention, non-acknowledged send failure, synchronous submission 
failure, executor bounds and shutdown; failed-callback unblock with sticky 
failure across write / flush / close, flush waiting for all callbacks, permit 
return on submission exception; seek recovery / exhaustion / non-transport / 
interruption boundaries. Existing writer tests now stub 
`InitContext.metricGroup()` because the constructor registers gauges.
   
   ## Verifications
   
   - JDK 11: `spotless:check` green; 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).
   - Acceptance matrix, 180 s warmup / 300 s sampling per scenario, 4 KiB, 32 
in-flight / 2 sender threads:
     - Sink TM 1 / 2 / 4 / 8, direct-connect: 29,668 / 56,905 / 106,638 / 
193,513 rec/s at 99.7–99.8% TM CPU.
     - Sink TM 1 / 2 / 4 / 8, proxy (12-core limit): 31,098 / 63,063 / 121,650 
/ 200,301 rec/s (before, synchronous: 2,528 / 6,269 / 11,527 / 16,397 rec/s at 
<10% TM CPU).
     - End-to-end TM8: 143,025 rec/s direct, 157,493 rec/s proxy; failure 
callbacks 0 and sampling-window checkpoint failures 0 in all 16 scenarios.
     - Send completion RT avg 0.6–2.0 ms, p99 (250 μs bucket upper bound) ≤ 2.0 
ms in the formal Sink scenarios.
   - Source TM8 startup with the seek retry: complete 302 s windows with 0 job 
restarts and 0 container restarts (before: `RemotingSendRequestException` 
exhausted the restart budget → terminal FAILED).
   
   Closes #153


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to