gaoyf opened a new issue, #9947:
URL: https://github.com/apache/rocketmq/issues/9947

   ### 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 22.04
   
   ### RocketMQ version
   
   5.3.1
   
   ### JDK Version
   
   Open Jdk 8
   
   ### Describe the Bug
   
   In RocketMQ 5.3.1, TimerMessageStore#checkAndReviseMetrics scans TimerLog 
files using a fixed step (TimerLog.UNIT_SIZE) until timeSbr.getSize().
   
   However, TimerLog write logic explicitly writes a BLANK record (with 
BLANK_MAGIC_CODE) when remaining space is insufficient for a full TimerLog 
unit, and then sets wrotePosition to fileSize.
   
   The BLANK record:
   
   is shorter than TimerLog.UNIT_SIZE
   
   is a valid end marker, not corrupted data
   
   But checkAndReviseMetrics does not recognize BLANK records, and still tries 
to decode them as a full TimerLog unit, which leads to:
   
   ```
   2025-12-23 05:08:37 ERROR TimerScheduledThread1 - 
[CheckAndReviseMetrics]Unknown error in checkAndReviseMetrics and abort
   java.nio.BufferUnderflowException: null
           at java.nio.Buffer.nextGetIndex(Buffer.java:506)
           at java.nio.DirectByteBuffer.getLong(DirectByteBuffer.java:772)
           at 
org.apache.rocketmq.store.timer.TimerMessageStore.checkAndReviseMetrics(TimerMessageStore.java:1237)
           at 
org.apache.rocketmq.store.timer.TimerMessageStore$3.run(TimerMessageStore.java:494)
           at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
           at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
           at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
           at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
           at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
           at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
           at java.lang.Thread.run(Thread.java:748)
   ```
   
   
   This exception is deterministic once a BLANK record exists at the end of a 
TimerLog file.
   
   ### Steps to Reproduce
   
   1. Start a RocketMQ Broker (5.3.x) with TimerMessageStore enabled
   2. Send timer messages continuously until a TimerLog mapped file is nearly 
full
   3. Ensure remaining space is less than TimerLog.UNIT_SIZE, so a BLANK record 
is written
   4. Wait for the scheduled checkAndReviseMetrics task to run
   5. Observe the following exception in broker logs
   
   ### What Did You Expect to See?
   
   No BufferUnderflowException 
   
   ### What Did You See Instead?
   
   BufferUnderflowException 
   
   ### Additional Context
   
   _No response_


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