[ISSUE #10421] Fix Timer message RocksDB cache key using ByteBuffer#10532
Open
itxaiohanglover wants to merge 1 commit into
Open
[ISSUE #10421] Fix Timer message RocksDB cache key using ByteBuffer#10532itxaiohanglover wants to merge 1 commit into
itxaiohanglover wants to merge 1 commit into
Conversation
Contributor
Review by github-manager-botSummaryFixes a cache key correctness bug in Findings
VerdictLGTM. Clean fix for a real correctness bug. Approved. Automated review by github-manager-bot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Fixes #10421
In the timer message RocksDB store,
DELETE_KEY_CACHE_FOR_TIMERis used to prevent anUPDATErecord from re-inserting an already-deleted key (which would leave a ghost record in RocksDB).However, the cache uses
byte[]as its key type. Sincebyte[].equals()compares object references rather than content, andTimerRocksDBRecord.getKeyBytes()returns a new byte array each time,cache.getIfPresent(keyBytes)always returnsnulleven when the same key content was previously put. As a result, theUPDATEpath always writes the record back, producing ghost records.Brief changelog
In
MessageRocksDBStorage.java:DELETE_KEY_CACHE_FOR_TIMERcache key type fromCache<byte[], byte[]>toCache<ByteBuffer, byte[]>.ByteBufferimplements content-basedequals()/hashCode(), so cache lookups match on key content rather than array identity.ByteBuffer.wrap(keyBytes)in bothcache.put(...)andcache.getIfPresent(...)calls.Verifying this change
DELETEbranch now correctly stores aByteBuffer-wrapped key, and theUPDATEbranch correctly retrieves it by content, so already-deleted keys are skipped as intended.java.nio.ByteBufferis already imported in the file, so no new imports are required.Follow this checklist to request a review from a maintainer:
./mvnw -T 2C clean checkstyle:check../mvnw -T 2C clean test -Dtest=...to make sure unit tests pass.