[Bug] compressedRegister=true makes broker registration fail: the register body is compressed but the header says it is not

Abierto
#11,425 2 comentarios 0 reacciones 0 asignados Ver en GitHub

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
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
java
Área
backend

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
  1. Set compressedRegister=true in broker.conf and start the broker with a name server.
  2. The broker logs Failed to register current broker to name server for every name server; on the name server side RegisterBrokerBody.decode fails to parse the compressed body as JSON (RemotingCommandException).
  3. Because registerBrokerAll collects results per name server and returns an empty list on failure, handleRegisterBrokerResult silently does nothing: the broker never appears in any route table, and producers/consumers get TOPIC_NOT_EXIST or 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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/rocketmq

Todos los issues de apache/rocketmq

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.