Skip to content
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

chore: improve Migration() #3033

Merged
merged 1 commit into from
May 28, 2024
Merged

chore: improve Migration() #3033

merged 1 commit into from
May 28, 2024

Conversation

kostasrim
Copy link
Contributor

  • add DCHECK
  • add comments to describe flows and correctness

@kostasrim kostasrim requested a review from dranikpg May 9, 2024 12:52
@kostasrim kostasrim changed the title chore: improve Migration code chore: improve Migration() May 9, 2024
@kostasrim kostasrim self-assigned this May 24, 2024
@@ -1331,6 +1339,7 @@ void Connection::DispatchFiber(util::FiberSocketBase* peer) {

uint64_t prev_epoch = fb2::FiberSwitchEpoch();
while (!builder->GetError()) {
DCHECK_EQ(socket()->proactor(), ProactorBase::me());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

Comment on lines 582 to +584

DCHECK(!dispatch_fb_.IsJoinable());

Copy link
Contributor

@dranikpg dranikpg May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check what happens with the dispatch fiber when it gets a message during migration?

Copy link
Contributor Author

@kostasrim kostasrim May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't? The connection migrates, before it does it joins the dispatch_fb_. At this point we got no messages and we are the active fiber on the thread we are executing. Then we suspend on the current thread and we continue our execution on the thread we migrate. During that time the dispatch_fb_ should stay joined (that is, it couldn't be restarted) since no other operation can or should really wake it -- thinking of ACL's here(since the connection won't even show up when it gets removed by the thread local connection table and when it becomes available again on the thread local of the migrated thread it will be the active fiber - so no other fiber can wake up its queue).

Am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically... we check that no subscriptions are active when we migrate and no command is ongoin, so there shouldn't be any, right.

We have this dcheck to catch it if it does. Maybe there will be a reason do so in the future and we'll forget this is a potential bug 🙂

@kostasrim kostasrim merged commit b89997c into main May 28, 2024
10 checks passed
@kostasrim kostasrim deleted the proper_migrations branch May 28, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants