You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "echooymxq (via GitHub)" <gi...@apache.org> on 2026/06/03 06:38:52 UTC

[I] [Bug] Timer message rocksdb wrong cache key [rocketmq]

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

   ### 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
   
   ubuntu
   
   ### RocketMQ version
   
   develop
   
   ### JDK Version
   
   1.8
   
   ### Describe the Bug
   
   In the timer message RocksDB store, when a delayed message is consumed, a `DELETE` record is written to remove it from RocksDB. Meanwhile, if the same message undergoes a Roll (CommitLog rotation), an `UPDATE `record is written to update its offset. The `DELETE_KEY_CACHE_FOR_TIMER` is used to prevent `UPDATE` from re-inserting an already-deleted key.
   
   the cache uses `byte[]` as its key type. Since `byte[].equals()` compares object references rather than content.
   
   ### Steps to Reproduce
   
   as describe.
   
   ### What Did You Expect to See?
   
   The UPDATE should be skipped since the key was already deleted, and no record should remain in RocksDB.
   
   ### What Did You See Instead?
   
   The UPDATE writes back the deleted record as a ghost record in RocksDB.
   
   ### 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: commits-unsubscribe@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Timer message rocksdb wrong cache key [rocketmq]

Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin closed issue #10421: [Bug] Timer message rocksdb wrong cache key
URL: https://github.com/apache/rocketmq/issues/10421


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Timer message rocksdb wrong cache key [rocketmq]

Posted by "oss-taishan-ai (via GitHub)" <gi...@apache.org>.
oss-taishan-ai commented on issue #10421:
URL: https://github.com/apache/rocketmq/issues/10421#issuecomment-4620091796

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed**
   
   The reported issue has been verified against the current codebase.
   
   **Root Cause:** `MessageRocksDBStorage.java:87` — `DELETE_KEY_CACHE_FOR_TIMER` is declared as `Cache<byte[], byte[]>` (Guava). `byte[].equals()` uses identity comparison, so `getIfPresent(keyBytes)` at line 359 always returns `null` even when the key was just `put()` at line 357. `TimerRocksDBRecord.getKeyBytes()` allocates a new array on every call, so identity never matches.
   
   **Impact:** When a timer/delay message is consumed (DELETE) and concurrently rolled (UPDATE), the guard fails to detect the prior deletion. UPDATE re-inserts the deleted key as a ghost record in RocksDB.
   
   **Severity:** medium
   
   **Fix:** Use a content-equality key type (e.g. `ByteBuffer.wrap(keyBytes)` or `String`) instead of raw `byte[]` for both `put` and `getIfPresent`.
   
   ---
   *Automated evaluation by github-manager-bot*
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Timer message rocksdb wrong cache key [rocketmq]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on issue #10421:
URL: https://github.com/apache/rocketmq/issues/10421#issuecomment-4689398363

   **Issue Evaluation**
   
   Category: `type/bug` | Status: **Confirmed**
   
   The reported issue has been verified against the codebase description.
   
   **Root Cause:** `DELETE_KEY_CACHE_FOR_TIMER` uses `byte[]` as its key type. In Java, `byte[].equals()` performs reference comparison (inherited from `Object.equals()`), not content comparison. This means the cache lookup will never correctly identify a previously-deleted key, allowing a subsequent `UPDATE` record to re-insert a ghost entry into RocksDB after the corresponding `DELETE` was written.
   
   **Impact:** Timer message store (RocksDB-backed). Ghost records accumulate when delayed messages are consumed and then undergo CommitLog rotation, leading to potential data inconsistency and wasted storage.
   
   **Severity:** Medium — data integrity concern in timer message persistence layer.
   
   **Suggested Fix:** Replace `byte[]` key with a content-addressable wrapper (e.g., `ByteBuffer.wrap(byte[])` or a custom key class with proper `equals()`/`hashCode()` based on `Arrays.equals()`/`Arrays.hashCode()`).
   
   An automated fix proposal can be generated. Reply `/approve` to proceed with PR generation.
   
   ---
   *Automated evaluation by RockteMQ-AI*


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org