-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: codis slot migrate #3233
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
base: unstable
Are you sure you want to change the base?
fix: codis slot migrate #3233
Changes from all commits
655745e
81f5c98
e041fb1
65715a0
b3d763e
29bfafa
2b63123
6d092c7
9526008
71d23c3
fb9a156
5771e2f
1292ab8
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 |
|---|---|---|
|
|
@@ -1439,10 +1439,28 @@ void SlotsMgrtExecWrapperCmd::Do() { | |
| res_.AppendArrayLen(2); | ||
| int ret = g_pika_server->SlotsMigrateOne(key_, db_); | ||
| switch (ret) { | ||
| case 0: | ||
| res_.AppendInteger(0); | ||
| res_.AppendInteger(0); | ||
| case 0: { | ||
| res_.AppendInteger(2); | ||
| PikaCmdArgsType args; | ||
| for (size_t i = 2; i < argv_.size(); ++i) { | ||
| args.push_back(argv_[i]); | ||
| } | ||
| std::string opt = args[0]; | ||
| pstd::StringToLower(opt); | ||
| std::shared_ptr<Cmd> c_ptr = g_pika_cmd_table_manager->GetCmd(opt); | ||
| if (!c_ptr) { | ||
| res_.SetRes(CmdRes::kErrOther, "unknown command"); | ||
| return; | ||
| } | ||
| c_ptr->Initial(args, db_->GetDBName()); | ||
| if (!c_ptr->res().ok()) { | ||
| res_.SetRes(CmdRes::kErrOther, c_ptr->res().message()); | ||
| return; | ||
| } | ||
| c_ptr->Execute(); | ||
|
Comment on lines
+1444
to
+1460
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. Reject wrapped commands that do not resolve back to This branch executes client-supplied 🔒 Suggested guardrails PikaCmdArgsType args;
for (size_t i = 2; i < argv_.size(); ++i) {
args.push_back(argv_[i]);
}
+ if (args.empty()) {
+ res_.SetRes(CmdRes::kWrongNum, kCmdNameSlotsMgrtExecWrapper);
+ return;
+ }
std::string opt = args[0];
pstd::StringToLower(opt);
std::shared_ptr<Cmd> c_ptr = g_pika_cmd_table_manager->GetCmd(opt);
if (!c_ptr) {
res_.SetRes(CmdRes::kErrOther, "unknown command");
return;
}
c_ptr->Initial(args, db_->GetDBName());
if (!c_ptr->res().ok()) {
res_.SetRes(CmdRes::kErrOther, c_ptr->res().message());
return;
}
+ const auto keys = c_ptr->current_key();
+ if (keys.size() != 1 || keys[0] != key_) {
+ res_.SetRes(CmdRes::kErrOther, "wrapped command must target the wrapper key");
+ return;
+ }
c_ptr->Execute();🤖 Prompt for AI Agents |
||
| res_.AppendStringRaw(c_ptr->res().message()); | ||
| return; | ||
| } | ||
| case 1: | ||
| res_.AppendInteger(1); | ||
| res_.AppendInteger(1); | ||
|
|
||
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.
Document the new
2result code.The contract immediately above
Do()still says this wrapper only returns-1/0/1, but Line 1443 now emits2. Please update the command contract/tests with the new discriminator so callers do not keep treating this path as an unknown response.🤖 Prompt for AI Agents