unbridled-41 opened a new pull request, #5893:
URL: https://github.com/apache/rocketmq-dashboard/pull/5893
### Which Issue(s) This PR Fixes
Fixes #5892
### Problem / Evidence
`GET /api/messages/page` computed one default window before it branched on
the query mode, so the key branch inherited the topic scan's hour:
```java
// server/.../provider/apache/RocketMQMessageProvider.java:129-136 (before)
long end = endTime != null ? endTime : System.currentTimeMillis();
long begin = startTime != null ? startTime : end - ONE_HOUR_MILLIS;
if (begin >= end) { throw new BusinessException(400, "Message query start
time must be before end time"); }
if (StringUtils.hasText(topic) && StringUtils.hasText(key)) {
return queryByKey(adminExt, topic, key, tag, begin, end);
}
```
Three independent things say that default does not belong to this branch:
1. `docs/api-spec.md:1500` scopes it to the scan - "未指定 `msgId` 或 `key` 的
Topic 扫描默认查询最近 1 小时".
2. A key lookup reads the broker's key index instead of scanning; the
sibling unique-key lookup in the same class already uses three days
(`UNIQUE_KEY_DEFAULT_WINDOW_MILLIS`, mirroring RocketMQ's own
`MQAdminImpl.queryMessageByUniqKey`).
3. The console cannot pass a window in key mode: `currentQueryParams` sends
`{topic, key}` and the RangePicker is rendered only for `queryMode === 'topic'`
(`web/src/pages/instance/message.tsx`), so the default is the only window a key
search can ever have.
Observed before the fix:
```
RocketMQMessageProviderTest#queryMessagesByKeyWithoutAWindowSearchesTheKeyDefaultNotTheTopicScanDefaultTest
expected: 259200000L
but was: 3600000L
```
### Root cause / Fix
Compute the default per branch: keep `ONE_HOUR_MILLIS` for the topic scan
and use the key-index default for a key lookup, and state the key default in
the API spec.
### Priority and scoring
**PRIORITY 62** — impact 26/40 (a primary triage path silently reports "no
results" for messages that exist, and the query history records it as a
successful empty query), blast radius 14/20 (every message-key lookup through
the console and the AI tool), reproducibility 18/20 (deterministic window
pinned by the new test), maintenance value 12/20 (two defaults of one function
disagreeing with the documented contract).
**FIX_CONFIDENCE 78** — one default per branch, mirrored from the sibling
lookup; the only judgement is which window, and the doc + sibling + parent
project all point at the wider one.
### Tests
`cd server && mvn -o -B -ntp test -Dtest='RocketMQMessageProviderTest'`
| Test | Before | After |
|---|---|---|
|
`queryMessagesByKeyWithoutAWindowSearchesTheKeyDefaultNotTheTopicScanDefaultTest`
| FAIL `expected: 259200000L but was: 3600000L` | PASS |
`Tests run: 62, Failures: 0, Errors: 0` in the class (the existing cases
pass an explicit window and are unaffected). `mvn -o -B -ntp checkstyle:check`
passes.
### Risk
The wider window means a key lookup now asks the broker for a larger range;
the broker's own index bounds what it can match, and the result set is still
capped by the existing 64-message budget the code already surfaces as
`mayBeTruncated`. The topic scan's documented hour is untouched.
--
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]