-
Notifications
You must be signed in to change notification settings - Fork 998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cluster): Allow appending RDB to existing store #3505
Changes from all commits
64d2d0b
921e3a7
e99f4a4
f047798
e39b34f
03f84ce
78231bd
f81254f
1c0e644
4650746
6183752
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,11 +163,33 @@ void DflyCmd::Run(CmdArgList args, ConnectionContext* cntx) { | |
return ReplicaOffset(args, cntx); | ||
} | ||
|
||
if (sub_cmd == "LOAD" && args.size() == 2) { | ||
DebugCmd debug_cmd{sf_, cntx}; | ||
debug_cmd.Load(ArgS(args, 1)); | ||
return; | ||
if (sub_cmd == "LOAD") { | ||
return Load(args, cntx); | ||
} | ||
|
||
if (sub_cmd == "HELP") { | ||
string_view help_arr[] = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It strange for me that help returns array, please consider to use R"()" string literal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a usual thing to return an array for commands in valkey There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, as a human user it's easier to see errors like this than |
||
"DFLY <subcommand> [<arg> [value] [opt] ...]. Subcommands are:", | ||
"THREAD", | ||
" Returns connection thread index and number of threads", | ||
"THREAD <thread-id>", | ||
" Migrates connection to thread <thread-id>", | ||
"EXPIRE", | ||
" Collects all expired items.", | ||
"REPLICAOFFSET", | ||
" Returns LSN (log sequence number) per shard. These are the sequential ids of the ", | ||
" journal entry.", | ||
"LOAD <filename> [APPEND]", | ||
" Loads <filename> RDB/DFS file into the data store.", | ||
" * APPEND: Existing keys are NOT removed before loading the file, conflicting ", | ||
" keys (that exist in both data store and in file) are overridden.", | ||
"HELP", | ||
" Prints this help.", | ||
}; | ||
auto* rb = static_cast<RedisReplyBuilder*>(cntx->reply_builder()); | ||
return rb->SendSimpleStrArr(help_arr); | ||
} | ||
|
||
cntx->SendError(kSyntaxErr); | ||
} | ||
|
||
|
@@ -500,6 +522,41 @@ void DflyCmd::ReplicaOffset(CmdArgList args, ConnectionContext* cntx) { | |
} | ||
} | ||
|
||
void DflyCmd::Load(CmdArgList args, ConnectionContext* cntx) { | ||
CmdArgParser parser{args}; | ||
parser.ExpectTag("LOAD"); | ||
string_view filename = parser.Next(); | ||
ServerFamily::LoadExistingKeys existing_keys = ServerFamily::LoadExistingKeys::kFail; | ||
|
||
if (parser.HasNext()) { | ||
parser.ExpectTag("APPEND"); | ||
existing_keys = ServerFamily::LoadExistingKeys::kOverride; | ||
} | ||
|
||
if (parser.HasNext()) { | ||
parser.Error(); | ||
} | ||
|
||
if (parser.HasError()) { | ||
return cntx->SendError(kSyntaxErr); | ||
} | ||
|
||
if (existing_keys == ServerFamily::LoadExistingKeys::kFail) { | ||
sf_->FlushAll(cntx); | ||
} | ||
|
||
if (auto fut_ec = sf_->Load(filename, existing_keys); fut_ec) { | ||
GenericError ec = fut_ec->Get(); | ||
if (ec) { | ||
string msg = ec.Format(); | ||
LOG(WARNING) << "Could not load file " << msg; | ||
return cntx->SendError(msg); | ||
} | ||
} | ||
|
||
cntx->SendOk(); | ||
} | ||
|
||
OpStatus DflyCmd::StartFullSyncInThread(FlowInfo* flow, Context* cntx, EngineShard* shard) { | ||
DCHECK(!flow->full_sync_fb.IsJoinable()); | ||
DCHECK(shard); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this code from below
We shouldn't get alerts for failing debug commands IMO