[kv] Fail multiGet on read errors instead of reporting missing keys - #4488
Open
zhang-arvin wants to merge 1 commit into
Open
zhang-arvin wants to merge 1 commit into
zhang-arvin wants to merge 1 commit into
Conversation
RocksDBKv#multiGet delegates to RocksDB#multiGetAsList, which reports a key that could not be read as null - the same value it uses to signal a genuine miss. A corrupted SST therefore turned a read error into a silent "key not found", while the single-key get() path correctly throws. Re-check every null result with get(), which throws on read errors. A genuine miss only pays one extra lookup and stays cheap as it is served from the bloom filter / block cache. Apply the same reasoning to prefixLookup() and limitScan(): an iterator stopped by an error is indistinguishable from one that reached the end of its range by isValid() alone, so check status() before closing it instead of silently truncating the result set. Fixes apache#4484
2 tasks
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.
Summary
RocksDBKv#multiGetdelegates toRocksDB#multiGetAsList, which reports a key that could not be read (e.g. a block checksum mismatch on a corrupted SST) asnull- the very same value it uses to signal a genuine miss. A read error was therefore silently turned into "key not found", while the single-keyget()path correctly throws.nullresult ofmultiGetAsListwithget(), which throws on read errors. A genuine miss only pays one extra lookup and stays cheap as it is served from the bloom filter / block cache.prefixLookup()andlimitScan(): an iterator stopped by an error is indistinguishable from one that reached the end of its range byisValid()alone, so the status is now checked before closing it instead of silently truncating the result set.throws IOException, matching the same pattern as the other read paths (KvTablet.prefixLookup/limitScanalready declare it, and their callers inReplicaalready catchIOExceptionand wrap it intoKvStorageException).Test Plan
RocksDBKvTest#testMultiGetFailsOnReadError, covering both sides of the change:multiGetfail instead of returningnull;nulland is not turned into an error by the added re-check.get(), the methodmultiGet()uses for the re-check. Corrupting an SST on disk does not work here: RocksDB opens a database withparanoid_checksenabled by default, so the instance fails to open at all and the read path is never reached.mvn -pl fluss-server test -Dtest=RocksDBKvTest: 13 tests, 0 failures, 0 errors.mvn -pl fluss-server spotless:applyandspotless:check: clean.Fixes #4484
🤖 AI-assisted changes - reviewed by human developer