[Bug] compressedRegister=true makes broker registration fail: the register body is compressed but the header says it is not
Los mantenedores suelen responder en 1 día
@iloveeyjafjalla ya está trabajando en esto.
Desde el 13/10/2026.
- #11426 de @iloveeyjafjalla — abierto
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 25/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- Java
- Estrellas
- 22.7k
- Forks
- 12k
- Merge medio
- 4 d 20 h
- PR fusionados (30 d)
- 11
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/rocketmq
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationPosiblemente ocupada @amalsaidov la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
CompressionType.of fails under the Turkish localePosiblemente ocupada @sharanggupta la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
[rocketmq-client-python] TransactionMQProducer allocates an unused producer during initializationAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
[Bug] notifyMasterOnline aborts the long-polling wake-up with a NullPointerException when an arrival drains a bucket firstPosiblemente ocupada @iloveeyjafjalla la tomó hace 29 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
apache/rocketmq#11441 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Enhancement] FilterFactory duplicate-registration and unregister semantics lack testsPosiblemente ocupada @chennaji9 la tomó hace 34 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
apache/rocketmq#11340 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/rocketmq
Issues similares
-
bug emitter:client:csharp
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
microsoft/typespec#12572 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 1 día
-
needs-area-label
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
area/ai area/backend component/zeebe kind/task
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
spAnser/reacharound#38 ·