-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: slotmigrate return not correct #2741
Changes from 3 commits
3a0a5bf
6166e47
fa5152b
bfc8ab4
57cea70
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 |
---|---|---|
|
@@ -654,11 +654,12 @@ int PikaMigrateThread::ReqMigrateOne(const std::string& key, const std::shared_p | |
key_type = storage::DataTypeToTag(type); | ||
if (type == storage::DataType::kNones) { | ||
LOG(WARNING) << "PikaMigrateThread::ReqMigrateOne key: " << key << " type: " << static_cast<int>(type) << " is illegal"; | ||
return -1; | ||
return 0; | ||
} | ||
|
||
if (slot_id != slot_id_) { | ||
LOG(WARNING) << "PikaMigrateThread::ReqMigrateOne Slot : " << slot_id << " is not the migrating slot:" << slot_id_; | ||
return -2; | ||
return -1; | ||
} | ||
|
||
// if the migrate thread exit, start it | ||
|
@@ -675,7 +676,7 @@ int PikaMigrateThread::ReqMigrateOne(const std::string& key, const std::shared_p | |
is_migrating_ = true; | ||
usleep(100); | ||
} | ||
} else { | ||
} | ||
// check the key is migrating | ||
std::pair<const char, std::string> kpair = std::make_pair(key_type, key); | ||
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. 代码往前缩一格 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.
done |
||
if (IsMigrating(kpair)) { | ||
|
@@ -686,7 +687,6 @@ int PikaMigrateThread::ReqMigrateOne(const std::string& key, const std::shared_p | |
mgrtone_queue_.emplace_back(kpair); | ||
luky116 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
NotifyRequestMigrate(); | ||
} | ||
} | ||
|
||
return 1; | ||
} | ||
|
@@ -934,7 +934,9 @@ void *PikaMigrateThread::ThreadMain() { | |
{ | ||
std::unique_lock lw(workers_mutex_); | ||
while (!should_exit_ && is_task_success_ && send_num_ != response_num_) { | ||
workers_cond_.wait(lw); | ||
if (workers_cond_.wait_for(lw, std::chrono::minutes(3)) == std::cv_status::timeout) { | ||
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. 这行代码是否还需要?可以删了? 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. !should_exit_ && is_task_success_ 这里我觉得不能删除 毕竟这个参数是异步赋值的如果没有赋值成功那线程就不会销毁 占用, |
||
break; | ||
} | ||
} | ||
} | ||
LOG(INFO) << "PikaMigrateThread::ThreadMain send_num:" << send_num_ << " response_num:" << response_num_; | ||
|
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.
这个判断还需要加吗?
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.
不对slot_id校验直接走下面逻辑塞进队列?
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.
嗯嗯,等于是不管这个 key 所属的 slot 是否在迁移,我都能把这个 key 迁走
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.
如果你不是所属迁移的slot你也不会进入到这里来吧,因为你不可能是migrating状态