[Bug] compressedRegister=true makes broker registration fail: the register body is compressed but the header says it is not
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
Direzione di ricerca
The header flag is hardcoded to false at requestHeader.setCompressed(false) in BrokerOuterAPI.java (around line 517), while the body is encoded with encode(compressed). Read RegisterBrokerBody.decode in the namesrv path and the existing RegisterBrokerBodyTest to confirm the expected pairing. Done means the captured register request's header flag matches its body, checked by a BrokerOuterAPITest case. A linked pull request (#11426) already exists, so review or extend it rather than starting a new fix.
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 (broker with compressedRegister=true in its configuration)
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
BrokerOuterAPI.registerBrokerAll compresses the register body when the broker has compression enabled, but hardcodes the header flag that tells the name server whether the body is compressed:
requestHeader.setCompressed(false); // BrokerOuterAPI.java:517
...
final byte[] body = requestBody.encode(compressed); // :525 — gzip when compressed == true
RegisterBrokerBody.encode(boolean compress) returns a deflate stream whenever compress is true (remoting/.../RegisterBrokerBody.java:51-55), and the name server decodes strictly by the flag it receives — RegisterBrokerBody.decode(request.getBody(), requestHeader.isCompressed(), brokerVersion) (namesrv/.../processor/DefaultRequestProcessor.java:298) → if (!compressed) { return RegisterBrokerBody.decode(data, RegisterBrokerBody.class); } (RegisterBrokerBody.java:115-117), i.e. it tries to parse the deflate stream as UTF-8 JSON.
The flag is wired from the configuration: BrokerController.doRegisterBrokerAll passes this.brokerConfig.isCompressedRegister() (BrokerController.java:2169), and registration runs at startup (registerBrokerAll(true, false, true), :1983) and periodically (:1998). The only value that makes the two lines agree is the default false, which is why this is not visible in normal deployments.
This is a regression from RIP-32: commit cad0cfcec ("feature(broker & acl & client):[RIP-32]Support Slave Acting Master mode (#3978)") changed requestHeader.setCompressed(compressed) into requestHeader.setCompressed(false) while keeping encode(compressed).
Steps to Reproduce
- Set
compressedRegister=trueinbroker.confand start the broker with a name server. - The broker logs
Failed to register current broker to name serverfor every name server; on the name server sideRegisterBrokerBody.decodefails to parse the compressed body as JSON (RemotingCommandException). - Because
registerBrokerAllcollects results per name server and returns an empty list on failure,handleRegisterBrokerResultsilently does nothing: the broker never appears in any route table, and producers/consumers getTOPIC_NOT_EXISTor route-not-found for every topic hosted by it.
At the unit level the existing harness broker/src/test/java/org/apache/rocketmq/broker/BrokerOuterAPITest.java already registers with compressed = true (the 11th argument, line ~197-207) but never inspects the request; capturing the RemotingCommand passed to nettyRemotingClient.invokeSync and decoding its body with the header's own flag fails deterministically.
What Did You Expect to See?
Either the body and the flag describe the same thing — requestHeader.setCompressed(compressed), so a compressed body is decompressed by the name server as the existing RegisterBrokerBodyTest requires (it encodes with encode(true) and decodes with decode(..., true, ...)) — or, if the compression feature is being removed, encode(false) with the flag left off. As it is, the feature is unusable and turning it on breaks the broker's registration completely.
What Did You See Instead?
compressedRegister=true silently prevents the broker from registering at all: the name server cannot parse the body, the failures are only logged, and the broker looks alive while being absent from every route table.
Additional Context
Minimal fix: requestHeader.setCompressed(compressed) at BrokerOuterAPI.java:517 (restoring the pre-RIP-32 line), with a test in BrokerOuterAPITest that captures the register request and asserts the header flag describes the captured body.
I will open a PR with that change plus the regression test (red before: the captured header says compressed=false for a compressed body and decoding it with that flag throws; green after: the flag matches and the body decodes).
- Lingua principale
- Java
- Stelle
- 22.7k
- Fork
- 12k
- Merge medio
- 4g 20h
- PR unite (30g)
- 11
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
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationForse già presa @amalsaidov l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
CompressionType.of fails under the Turkish localeForse già presa @sharanggupta l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
[rocketmq-client-python] TransactionMQProducer allocates an unused producer during initializationAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] notifyMasterOnline aborts the long-polling wake-up with a NullPointerException when an arrival drains a bucket firstForse già presa @iloveeyjafjalla l’ha presa 29 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
apache/rocketmq#11441 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement] FilterFactory duplicate-registration and unregister semantics lack testsForse già presa @chennaji9 l’ha presa 34 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
Tutte le issue di apache/rocketmq
Issue simili
-
bug emitter:client:csharp
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
microsoft/typespec#12572 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 1 giorno
-
needs-area-label
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
area/ai area/backend component/zeebe kind/task
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
spAnser/reacharound#38 ·