-
Notifications
You must be signed in to change notification settings - Fork 473
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
Support blocking migration for the cluster migrate command #1418
Conversation
@torwig @PragmaTwice The reason why I use When the |
@ellutionist Thanks for your explanation. I have not dived into these changes deeply, but if you just want to make lifetime of SyncMigrateContext as long as the command object, you can store an instance of SyncMigrateContext in CommandClusterX directly ( |
I agree with that |
@PragmaTwice @xiaobiaozhao Thank you for the advice. This is another reasonable solution. However, there are two things to note here:
|
Sure, you can use something like
I think in kvrock, we use So currently, just "in the future ..." seems not to be an accredited reason to me, since if this reason holds, we may need to change many raw pointer in the codebase to |
Thank you. I got the point of the difference between dynamic and static lifetime. From this point of view the |
Hi @ellutionist Need to use |
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.
Not familiar with networking logic in kvrocks, so just some style comments
src/cluster/sync_migrate_context.cc
Outdated
|
||
void SyncMigrateContext::EventCB(bufferevent *bev, int16_t events, void *ctx) { | ||
auto self = reinterpret_cast<SyncMigrateContext *>(ctx); | ||
auto &&slot_migrator = self->svr_->slot_migrator; |
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.
Why using auto &&
here?
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.
This is a reference to std::unique_ptr<SlotMigrator>
, which cannot be copied.
Technically auto&
would suffice, but I personally prefer auto&&
since it accepts more kinds of value (e.g. const
, not this case though).
Of course, it is also okay to use auto slot_migrator = self->svr_->slot_migrator.get()
(raw pointer) here. Just a choice of style.
src/cluster/sync_migrate_context.cc
Outdated
|
||
void SyncMigrateContext::TimerCB(int, int16_t events, void *ctx) { | ||
auto self = reinterpret_cast<SyncMigrateContext *>(ctx); | ||
auto &&slot_migrator = self->svr_->slot_migrator; |
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.
ditto
Done. It took me a while to adapt to the recent changes from [#1420]. Also some more go test cases were added. |
The implementation generally looks good to me, left a few comments:
|
Seems need run
Currently we need to make them public for the CRTP base classes to use them. |
OK, I didn't notice this limitation. |
Looks like the migration test case has a segment fault. https://github.com/apache/incubator-kvrocks/actions/runs/4951001502/jobs/8855626634?pr=1418 |
I think I found the reason. When building with ASAN the pointer of context won't initialize with |
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.
LGTM
Merging... Thanks for your contribution! |
This PR closes 1350.