Skip to content

[#10421] Fix Timer message rocksdb use wrong cache key.#10422

Open
echooymxq wants to merge 1 commit into
apache:developfrom
echooymxq:10421
Open

[#10421] Fix Timer message rocksdb use wrong cache key.#10422
echooymxq wants to merge 1 commit into
apache:developfrom
echooymxq:10421

Conversation

@echooymxq
Copy link
Copy Markdown
Contributor

Fix #10421

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.01%. Comparing base (2a9560c) to head (e6bf55a).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10422      +/-   ##
=============================================
- Coverage      48.05%   48.01%   -0.04%     
+ Complexity     13303    13299       -4     
=============================================
  Files           1377     1377              
  Lines         100611   100612       +1     
  Branches       12991    12991              
=============================================
- Hits           48347    48310      -37     
  Misses         46348    46348              
- Partials        5916     5954      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@echooymxq
Copy link
Copy Markdown
Contributor Author

@zk-drizzle help review it.

Copy link
Copy Markdown

@oss-taishan-ai oss-taishan-ai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by github-manager-bot

Summary

Fixes #10421DELETE_KEY_CACHE_FOR_TIMER used raw byte[] as Guava cache key, causing identity-based lookups to always miss. Switches to ByteBuffer for content-equality semantics.

Findings

  • [Correctness] ✅ Changing cache key from byte[] to ByteBuffer properly uses content-based equals()/hashCode(), which is the correct fix for the ghost record issue.
  • [Correctness] ⚠️ Line 87-88: The cache declaration Cache<byte[], byte[]> appears unchanged in the diff — please verify the cache type is also updated to Cache<ByteBuffer, byte[]> to match the ByteBuffer.wrap() calls at lines 357 and 359.
  • [Correctness] ⚠️ ByteBuffer.wrap(keyBytes).equals() compares from position() to limit(). Since wrap() sets position=0 and limit=array.length, this works correctly for equal-length arrays. However, if key lengths could differ, consider using ByteBuffer.wrap(keyBytes, offset, length) consistently.
  • [Tests] ⚠️ No new tests visible in this diff. The bug is about cache key identity vs equality — recommend adding a unit test that verifies DELETE + UPDATE for the same timer key results in the UPDATE being correctly skipped.
  • [Compatibility] ✅ No public API changes. Internal implementation detail only.

Suggestions

  1. Ensure cache type declaration matches usage: Cache<ByteBuffer, byte[]> (not Cache<byte[], byte[]>)
  2. Add a test case that creates a DELETE record and an UPDATE record for the same timer key, and verifies the UPDATE does not re-insert the deleted key
  3. Consider adding a brief comment explaining why ByteBuffer is used instead of byte[] (identity vs content equality)

Automated review by github-manager-bot

Copy link
Copy Markdown
Contributor

@3424672656 3424672656 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Timer message rocksdb wrong cache key

5 participants