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

Fix PromoteReplica call in ERS #15934

Merged
merged 8 commits into from
May 22, 2024
Merged

Conversation

GuptaManan100
Copy link
Member

@GuptaManan100 GuptaManan100 commented May 14, 2024

Description

As described in #15935, running PromoteReplica before calling SetReplicationSource on the replicas is an issue as it can cause PromoteReplica to indefinitely hang.

This PR fixes 2 issues -

  1. We now run PromoteReplica in parallel with SetReplicationSource. This also allows us to not run the PrimaryPosition RPC separately, since PromoteReplica also returns the position of the primary.
  2. We should be using a context that has a timeout when running any RPC calls. Previously PromoteReplica and InitPrimary both were being called without adding a context timeout. This has also been fixed now.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Signed-off-by: Manan Gupta <manan@planetscale.com>
… set replication source

Signed-off-by: Manan Gupta <manan@planetscale.com>
Copy link
Contributor

vitess-bot bot commented May 14, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels May 14, 2024
@github-actions github-actions bot added this to the v20.0.0 milestone May 14, 2024
@GuptaManan100 GuptaManan100 added Type: Bug Component: Cluster management and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels May 14, 2024
@GuptaManan100 GuptaManan100 changed the title Ers fix Fix PromoteReplica call in ERS May 14, 2024
@GuptaManan100 GuptaManan100 marked this pull request as ready for review May 14, 2024 07:32
Copy link

codecov bot commented May 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.46%. Comparing base (3b09eb2) to head (392845f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15934      +/-   ##
==========================================
- Coverage   68.47%   68.46%   -0.02%     
==========================================
  Files        1562     1562              
  Lines      197083   197080       -3     
==========================================
- Hits       134962   134936      -26     
- Misses      62121    62144      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@deepthi deepthi left a comment

Choose a reason for hiding this comment

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

I have a few comments that I think are important to resolve before this can be merged.
Also, can we create a test case for the context fix? We'd have to write the test without this PR's changes first and make sure it fails, and that it passes with this PR.

go/vt/vtctl/reparentutil/emergency_reparenter.go Outdated Show resolved Hide resolved
go/vt/vtctl/reparentutil/emergency_reparenter.go Outdated Show resolved Hide resolved
go/vt/vtctl/reparentutil/emergency_reparenter.go Outdated Show resolved Hide resolved
go/vt/vtctl/reparentutil/emergency_reparenter.go Outdated Show resolved Hide resolved
Signed-off-by: Manan Gupta <manan@planetscale.com>
@GuptaManan100
Copy link
Member Author

@deepthi Added the test as well, which I ensured failed before the changes.

Signed-off-by: Manan Gupta <manan@planetscale.com>
Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

Where did this change? It was not apparent to me:

We now run PromoteReplica in parallel with SetReplicationSource

I wanted to understand and confirm that part (sorry if I just missed something obvious). Other than that, just minor comments.

go/test/endtoend/reparent/newfeaturetest/reparent_test.go Outdated Show resolved Hide resolved
go/vt/vtctl/reparentutil/emergency_reparenter.go Outdated Show resolved Hide resolved
go/vt/vtctl/reparentutil/emergency_reparenter.go Outdated Show resolved Hide resolved
@GuptaManan100
Copy link
Member Author

Thank you for the review @mattlord. I'll work on addressing them 👍.

As far as the changes for running PromoteReplica in parallel, earlier we would call PromoteReplica and then the reparentReplicas function. Now, we call PromoteReplica as part of handlePrimary in reparentReplicas. handlePrimary runs in parallel with handleReplica which runs SetReplicationSource.

Signed-off-by: Manan Gupta <manan@planetscale.com>
@mattlord
Copy link
Contributor

Thank you for the review @mattlord. I'll work on addressing them 👍.

As far as the changes for running PromoteReplica in parallel, earlier we would call PromoteReplica and then the reparentReplicas function. Now, we call PromoteReplica as part of handlePrimary in reparentReplicas. handlePrimary runs in parallel with handleReplica which runs SetReplicationSource.

OK, I see. So here: https://github.com/vitessio/vitess/pull/15934/files#diff-aace4cbbbebad37f5072421e16ca464c0f0b4eb98ad287380c2c764d11e7b836R310-R311

We're calling the reparentReplicas function — which does the promotion of the new primary and the replica reparents — instead of doing those two things serially. Now that I've looked at that reparentReplicas function I can see what you meant (it uses goroutines for each higher level task of promotion and reparent). Thanks!

Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

I only had minor comments/requests left so approving so that you can merge when you've addressed those as you feel is best.

Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Manan Gupta <manan@planetscale.com>
@GuptaManan100
Copy link
Member Author

Thank you @mattlord! I've addressed all the review comments, and just waiting for the tests now! 🚀

@GuptaManan100 GuptaManan100 merged commit cf06f60 into vitessio:main May 22, 2024
93 checks passed
@GuptaManan100 GuptaManan100 deleted the ers-fix branch May 22, 2024 03:25
GuptaManan100 added a commit that referenced this pull request May 22, 2024
Signed-off-by: Manan Gupta <manan@planetscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug Report: ERS fails if PromoteReplica runs a write
3 participants