[Bug] DefaultMQPushConsumer.shutdown() never stops the pop consume service, so its non-daemon threads keep the JVM alive
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 65/100
Direzione di ricerca
Inizia da client/.../impl/consumer/DefaultMQPushConsumerImpl.java: il normale percorso di shutdown intorno alla riga 908 ferma solo consumeMessageService, e il ramo di avvio fallito intorno alle righe 991-993 fa lo stesso. Aggiungi una chiamata di shutdown a consumeMessagePopService in entrambi i punti, seguendo il servizio non-pop. È completato quando DefaultMQPushConsumerImplTest, usando il consumeMessagePopService mockato e testShutdown, verifica che lo shutdown del servizio pop venga chiamato. Controlla prima i due commenti, perché chi ha segnalato il problema dice di voler aprire lui stesso la PR.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Before Creating the Bug Report
- I found a bug, not just asking a question, which should be created in GitHub Discussions.
- I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.
- I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.
Runtime platform environment
OS: any (client side, DefaultMQPushConsumer)
RocketMQ version
branch: develop
Git commit id: a7edeecfb
JDK Version
Compiler: Temurin 1.8.0_504 (target 1.8, same as CI)
Describe the Bug
DefaultMQPushConsumerImpl.start() creates and starts two consume services, but shutdown() stops only the first one:
this.consumeMessageService.start();
// POPTODO
this.consumeMessagePopService.start(); // DefaultMQPushConsumerImpl.java:984-986
case RUNNING:
this.consumeMessageService.shutdown(awaitTerminateMillis); // :908 — the pop service is never stopped
The pop service is not idle after it is started: ConsumeMessagePopOrderlyService.start() schedules lockMQPeriodically() at a fixed rate on a single-thread executor created with new ThreadFactoryImpl("ConsumeMessageScheduledThread_") (client/.../ConsumeMessagePopOrderlyService.java:64-77), and ThreadFactoryImpl creates non-daemon threads by default (common/.../ThreadFactoryImpl.java:35, :59). ConsumeMessagePopConcurrentlyService.start() likewise starts its consume executor. Both services implement shutdown(long) (ConsumeMessagePopOrderlyService.java:80-88, ConsumeMessagePopConcurrentlyService.java:70), and no code in the client module ever calls it — the only references to the field are the two assignments, start() and submitPopConsumeRequest.
The same omission exists in the failed-start branch, which stops only consumeMessageService when the consumer group is already registered (DefaultMQPushConsumerImpl.java:991-993).
Steps to Reproduce
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("group"); consumer.subscribe("topic", "*"); consumer.registerMessageListener(listener);consumer.start(); consumer.shutdown();- The pop service is still running: for CLUSTERING (the default) the
ConsumeMessageScheduledThread_thread keeps firinglockMQPeriodically()everyREBALANCE_LOCK_INTERVALon an empty process-queue table, the threads are non-daemon, so a JVM that relies on the consumer's shutdown to release its resources never terminates.
At the unit level the existing harness covers it: DefaultMQPushConsumerImplTest already injects a mocked consumeMessagePopService (line ~250-254) and has a testShutdown, so asserting that the service is shut down with shutdown() fails deterministically today.
What Did You Expect to See?
DefaultMQPushConsumer.shutdown() "shut down this client and releasing underlying resources" (client/.../consumer/DefaultMQPushConsumer.java:789) — i.e. both consume services are stopped, exactly like the non-pop one in the same method. The pop services' own shutdown(long) methods are the proof that this was the intent.
What Did You See Instead?
After shutdown() the consumer's pop scheduler (and, for pop consumers, the pop consume executor) keeps running with non-daemon threads; the client appears stopped (serviceState = SHUTDOWN_ALREADY) while resources are still held, which can leave the JVM unable to exit.
Additional Context
Minimal fix: stop consumeMessagePopService next to consumeMessageService in both places — the normal shutdown path and the register-failure path.
I will open a PR with those two one-line changes plus a regression test in DefaultMQPushConsumerImplTest (red before: the pop service receives no shutdown call).
- Lingua principale
- Java
- Stelle
- 22.6k
- Fork
- 12k
- Merge medio
- 7g 15h
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/rocketmq
-
[Enhancement] FilterFactory duplicate-registration and unregister semantics lack testsForse già presa @chennaji9 l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
apache/rocketmq#11340 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement] LogicExpression three-valued truth table and short-circuit behavior lack direct testsForse già presa @chennaji9 l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/rocketmq#11339 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement] SyncStateInfo defensive-copy and epoch semantics lack direct testsForse già presa @chennaji9 l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/rocketmq#11338 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement] ControllerClosure request-completion semantics lack direct testsForse già presa @chennaji9 l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/rocketmq#11337 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement] SemaphoreReleaseOnlyOnce lacks direct tests for its exactly-once release contractForse già presa @chennaji9 l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/rocketmq#11336 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/rocketmq
Issue simili
-
RRateLimiter acquire methods accept negative permits and raise available permits above the rate.Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 4 giorni
-
README 中的代码语言数量与当前目录不一致Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
krahets/hello-algo#1993 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
NationalSecurityAgency/ghidra#9884 ·
I maintainer di solito rispondono entro 2 giorni
-
Status: Pending Review Type: Feature Request
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
OpenRefine/OpenRefine#8019 ·
I maintainer di solito rispondono entro 1 giorno
-
[TEMP] pin maven version to 3.9.xForse già presa @petrenyi-mark l’ha presa oggi. Aperta
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 62/100