zjncs opened a new pull request, #5519:
URL: https://github.com/apache/rocketmq-dashboard/pull/5519
## Problem
`buildConsumerStatus` hardcodes the retry count:
```java
private ConsumerStatusVO buildConsumerStatus(String[] f) {
return ConsumerStatusVO.builder()
...
.retryCount(0) // ← always zero
.build();
}
```
A message's retry count lives **only in the SubBefore trace context**
(verified against `TraceDataEncoder.fromTraceData` in rocketmq-client 5.5.0 —
the decoder maps SubBefore field 6 to `TraceBean.setRetryTimes`):
```
SubBefore = type, timeStamp, regionId, groupName, requestId, msgId,
retryTimes
```
and the trace parser **dropped SubBefore contexts entirely** (`default:`
branch: "SubBefore and unknown types are not surfaced as timeline nodes").
Consequence: retried deliveries were never flagged — the frontend's retry
diagnostics (`retryCount > 0` → warning severity + retry issue,
`messageTraceDiagnostics.ts`) could never fire, because the backend always
reported 0.
## Fix
Collect the SubBefore retry count keyed by **requestId** — the encoder
stamps the same requestId on the SubBefore and SubAfter of one consume attempt
(both are set from the same `TraceContext` in the consume hook) — and join it
into the SubAfter-built consumer status:
- `case "SubBefore": retryByRequestId.put(field(f, 4), (int)
parseLong(field(f, 6)));`
- `buildConsumerStatus(fields, retryByRequestId.getOrDefault(field(f, 1),
0))`
The join map lives at the **query level** (both `getMessageTrace` and
`getMessageTraceByKey`), not per trace body: an attempt's SubBefore and
SubAfter can be flushed into different trace messages, and trace messages are
processed in store order so the before-context precedes its after-context.
Attempts without a SubBefore (older traces, partial data) keep `retryCount =
0` — the previous behavior.
Also fixes a silently-skipped test:
`getMessageTraceParsesBatchedPubAndSubAfterContexts` was missing its `@Test`
annotation and never ran; it now runs and passes.
## Verification
New tests in `RocketMQMessageProviderTest` (trace bodies built with the
file's existing `traceContext`/`traceBody` fixtures):
- `getMessageTraceJoinsSubBeforeRetryTimesIntoConsumerStatus` —
SubBefore(retry=3) + SubAfter(false) in one body;
- `getMessageTraceJoinsRetryAcrossSeparateTraceMessages` — SubBefore and its
SubAfter in **separate** trace messages (join survives across the query result).
Evidence chain:
- before the fix: **2 failed** — `retryCount` was `0` where 3 / 2 were
expected;
- after: **61/61** in `RocketMQMessageProviderTest` (including the
newly-running pre-existing parse test);
- mutation (revert the provider): back to 2 failed; restore: 61/61;
- regression: `MessageServiceTest` + `MessageTraceToolHandlerTest` —
**86/86** across the three classes.
No collision with open PRs (#5402/#5360 trace-topic handling, #5387/#5368
retry dialogs — all different functions).
--
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]