fix(kvrocks2redis): translate FLUSHDB/FLUSHALL via DeleteRange (#2177) - #3564
Open
advisedy wants to merge 4 commits into
Open
fix(kvrocks2redis): translate FLUSHDB/FLUSHALL via DeleteRange (#2177)#3564advisedy wants to merge 4 commits into
advisedy wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a replication/kvrocks2redis gap where FLUSHDB/FLUSHALL implemented as RocksDB DeleteRange on the metadata CF was previously dropped (no-op extraction) and thus never translated into equivalent Redis commands downstream—especially problematic when namespace replication is enabled.
Changes:
- Update
Database::FlushAllto emit one metadata-DeleteRangeper namespace (so ranges can be mapped back to namespaces). - Implement
WriteBatchExtractor::DeleteRangeCFtranslation of namespace-wide metadataDeleteRangeinto per-namespaceFLUSHDB, with warnings for unrecognized ranges. - Add Go integration coverage for cross-namespace replication and C++ unit tests for the extractor behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/gocase/integration/replication/replication_test.go |
Adds an integration test reproducing #2177 with repl-namespace-enabled=yes and verifying FLUSHALL replicates across namespaces. |
tests/cppunit/batch_extractor_test.cc |
Adds gtests validating DeleteRangeCF→FLUSHDB translation and handling of unsupported ranges. |
src/storage/redis_db.cc |
Changes FlushAll to emit per-namespace DeleteRange operations in a single write batch. |
src/storage/batch_extractor.cc |
Implements DeleteRangeCF handling for metadata range deletes, translating whole-namespace ranges into FLUSHDB. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
Hi, @git-hulk , @PragmaTwice ,just friendly ping on this one, whenever you have some time. Thanks! |
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.
Fixes #2177.
Problem
FLUSHDB/FLUSHALLis implemented viaDeleteRangeon the metadataCF, but the replication path did not propagate it:
WriteBatchExtractor::DeleteRangeCFwas a no-op, so the delete wassilently dropped and never translated into a Redis command on replicas
or kvrocks2redis.
Database::FlushAllmerged all namespaces into a singleDeleteRange,which could not be mapped back to any specific namespace.
Fix
FlushAllnow emits oneDeleteRangeper namespace in the same batch.DeleteRangeCFtranslates those ranges into a per-namespaceFLUSHDB,and rejects unrecognized ranges with a warning.
Tests
TestReplicationFlushDBAcrossNamespaces:reproduces the issue with
repl-namespace-enabled=yes.batch_extractor_test.ccfor single-namespaceFLUSHDB,multi-namespace
FLUSHALL, and unrecognized ranges.AI-assisted contribution
The tests were generated by an LLM. I reviewed all of them to make sure
they are correct and meaningful.
Scope
Only covers plain
FLUSHDB/FLUSHALL. TheMULTI/EXECcasementioned in #2177 is not handled here — I'm not sure what kind of
approach would fit best, and would appreciate reviewer input.