tju-yxq opened a new issue, #1411:
URL: https://github.com/apache/rocketmq-dashboard/issues/1411

   ## Bug Report
   
   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   - [x] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions) of this repository 
and believe that this is not a duplicate.
   - [x] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   ### Runtime platform environment
   
   OS: Ubuntu 20.04 / Any OS running RocketMQ Studio
   
   ### RocketMQ version
   
   branch: rocketmq-studio
   version: 5.3.2+
   Git commit id: f727341
   
   ### JDK Version
   
   OpenJDK 21
   
   ### Describe the Bug
   
   `RocketMQMessageProvider.getMessageTrace()` uses a hardcoded **1-hour 
lookback window** to query `RMQ_SYS_TRACE_TOPIC` for a message's trace data. If 
a message was produced more than 1 hour ago, the trace query finds nothing and 
returns an empty trace graph, even though the trace data still exists on the 
broker (RocketMQ default retention is 72 hours).
   
   ```java
   long now = System.currentTimeMillis();
   long begin = now - ONE_HOUR_MILLIS;   // hardcoded 1 hour lookback
   long end = now + 60_000L;
   QueryResult traceResult = adminExt.queryMessage(TRACE_TOPIC, msgId, 
TRACE_QUERY_MAX, begin, end);
   ```
   
   This is especially problematic because:
   
   - **Message queries support time ranges up to 24 hours** (`ONE_DAY_MILLIS` 
is defined but only used for the default query window, not for trace queries).
   - Users can find and click on messages that are up to 24 hours old, but 
clicking "View Trace" on any message older than 1 hour returns an empty result 
with no explanation.
   - The bug is **silent** - no error or warning is logged when zero trace 
results are returned.
   
   ### Steps to Reproduce
   
   1. Start a RocketMQ cluster with tracing enabled (`traceTopicEnable=true`).
   2. Produce a message and wait 2 hours.
   3. In RocketMQ Studio, query the message by message ID or topic + time range 
(set start time to 3 hours ago).
   4. The message is found and displayed.
   5. Click "View Trace" on the message.
   6. Observe: the trace graph is empty (zero nodes, zero consumer status 
entries).
   7. Verify on the broker that trace data exists: `mqadmin queryMsgByKey -t 
RMQ_SYS_TRACE_TOPIC -k <msgId>`.
   
   ### What Did You Expect to See?
   
   The trace graph should display all available trace nodes for the message, 
regardless of when it was produced, as long as the trace data is still retained 
on the broker.
   
   ### What Did You See Instead?
   
   An empty trace graph with no nodes and no error indication.
   
   ### Additional Context
   
   **Affected file**: 
`server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQMessageProvider.java`,
 method `getMessageTrace()` at approximately line 253.
   
   **Fix approach**:
   
   Before querying the trace topic, fetch the original message to obtain its 
`storeTimestamp`, then derive the trace query window from that timestamp 
instead of the current time:
   
   1. Call `adminExt.viewMessage(msgId)` to get the message's `storeTimestamp`.
   2. Set `begin` to `storeTimestamp - 5 minutes` (buffer for pre-produce trace 
events).
   3. Set `end` to `max(storeTimestamp + 24h, now + 1min)` (cover delayed 
consumption and transaction resolution).
   4. If the message can't be fetched (expired, wrong ID), fall back to the 
current 1-hour window with a warning log.
   
   This adds approximately 25 lines (a helper method + window calculation) 
while preserving the existing behavior as a fallback.
   


-- 
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]

Reply via email to