7sen commented on issue #1323:
URL:
https://github.com/apache/rocketmq-clients/issues/1323#issuecomment-7008123683
## Java SDK: same inflight-count leak family? Sequential container stops
make shutdown cost N × (requestTimeout + longPollingTimeout)
Confirming this design family (`InflightRequestCountInterceptor` +
`waitingReceiveRequestFinished`, introduced by PR #992) has a Java-side
operational impact consistent with #1323.
**Environment**
- rocketmq-client-java 5.1.0 (observed likewise on 5.0.7 path), Spring Boot
2.7.2, rocketmq-v5-client-spring-boot-starter 2.3.6 (which pins 5.0.7 —
overridden to 5.1.0 on our side)
- One application process, 10 `@RocketMQMessageListener` push consumers,
low-traffic topics in a test env (proxy mode, long polling)
**Observed shutdown behavior** (thread dumps captured via `kill -3` before
SIGKILL fallback):
Waiting side, elapsed ≈ 91s:
```
"SpringApplicationShutdownHook" ... waiting on condition
at
org.apache.rocketmq.client.java.impl.consumer.PushConsumerImpl.close(PushConsumerImpl.java:482)
at
org.apache.rocketmq.client.support.DefaultListenerContainer.stop(DefaultListenerContainer.java:316)
at
org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(...)
at
org.springframework.boot.SpringApplicationShutdownHook.closeAndWait(SpringApplicationShutdownHook.java:145)
```
Working side, elapsed ≈ 11.65s (i.e. this consumer only began its wait after
~78s had already been spent by earlier containers):
```
"PushConsumerImpl-4 STOPPING" ... TIMED_WAITING (sleeping)
at java.util.concurrent.TimeUnit.sleep(TimeUnit.java:446)
at
org.apache.rocketmq.client.java.impl.consumer.PushConsumerImpl.waitingReceiveRequestFinished(PushConsumerImpl.java:241)
at
org.apache.rocketmq.client.java.impl.consumer.PushConsumerImpl.shutDown(PushConsumerImpl.java:217)
at shaded
com.google.common.util.concurrent.AbstractIdleService$DelegateService.lambda$doStop$1(...)
```
**Reading of it**
1. `waitingReceiveRequestFinished()` is bounded (requestTimeout +
longPollingTimeout), but if the inflight receive count never reaches 0 — e.g.
the MESSAGE_NOT_FOUND expiry path leaves a pending increment, the same shape as
#1323 in Go — **every** consumer pays the full ~33s window on shutdown.
2. Spring's `DefaultLifecycleProcessor` stops `SmartLifecycle` containers
**sequentially**, so the per-consumer penalty multiplies: 10 consumers ⇒
worst-case ~330s of context close, which no deploy-side SIGTERM timeout can
ride out. Operators end up with SIGKILL as the de-facto shutdown path and
RocketMQ at-least-once redelivery for in-flight messages.
3. On the healthy fast path (idle, counter reaches 0) shutdown exits in
seconds, which is why this reproduces intermittently and mostly on
multi-consumer apps.
**Questions / asks**
- Is the inflight-count decrement on the no-new-message / MESSAGE_NOT_FOUND
long-poll expiry path symmetric on the Java side too (equivalent of the
`isNoNewMessage` branch in Go's `process_queue.go`), or is the full-window wait
here caused by genuinely in-flight long polls that are simply never cancelled
at stop?
- Would you consider: (a) cancelling/promptly completing pending receive
RPCs when the consumer transitions to stopping, and/or (b) making the drain
wait concurrent across consumers inside one client, so shutdown cost is
O(1×window) instead of O(N×window)?
Happy to provide full thread dumps and broker-side long-poll stats if
useful. Currently mitigated deploy-side (bounded SIGTERM wait + SIGKILL
fallback), but the app's graceful MQ drain is effectively unreachable with >1
consumers.
--
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]