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

Respect tolerable replication lag even when the new primary has been provided in PRS #15090

Merged
merged 3 commits into from
Feb 4, 2024

Conversation

GuptaManan100
Copy link
Member

@GuptaManan100 GuptaManan100 commented Jan 30, 2024

Description

This PR fixes the bug described in #15089.
Now when running PRS, if both the new primary and the tolerable replication lag has been provided, we will check that the new primary tablet actually has a replication lag lower than what we can tolerate, otherwise we'll fail the PRS quickly.

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

…en when the new primary is provided

Signed-off-by: Manan Gupta <[email protected]>
Copy link
Contributor

vitess-bot bot commented Jan 30, 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 Jan 30, 2024
@github-actions github-actions bot added this to the v19.0.0 milestone Jan 30, 2024
@GuptaManan100 GuptaManan100 added Type: Enhancement Logical improvement (somewhere between a bug and feature) 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 Jan 30, 2024
Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Attention: 383 lines in your changes are missing coverage. Please review.

Comparison is base (eddb39e) 47.29% compared to head (87d04bd) 40.88%.
Report is 98 commits behind head on main.

Files Patch % Lines
go/vt/proto/vtctldata/vtctldata_vtproto.pb.go 0.00% 157 Missing ⚠️
go/vt/vtgate/evalengine/cached_size.go 21.21% 25 Missing and 1 partial ⚠️
go/vt/mysqlctl/backupengine.go 9.09% 20 Missing ⚠️
go/vt/vtctl/workflow/traffic_switcher.go 0.00% 20 Missing ⚠️
go/vt/mysqlctl/builtinbackupengine.go 5.88% 16 Missing ⚠️
.../vtgate/planbuilder/operators/delete_with_input.go 48.27% 14 Missing and 1 partial ⚠️
go/vt/vtgate/evalengine/expr_tuple_bvar.go 64.10% 10 Missing and 4 partials ⚠️
go/vt/vtctl/workflow/server.go 84.31% 6 Missing and 2 partials ⚠️
go/vt/vtgate/engine/delete_with_input.go 83.33% 5 Missing and 3 partials ⚠️
go/vt/vtgate/evalengine/fn_time.go 91.13% 3 Missing and 4 partials ⚠️
... and 35 more
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #15090       +/-   ##
===========================================
- Coverage   47.29%   40.88%    -6.42%     
===========================================
  Files        1137     1453      +316     
  Lines      238684   368141   +129457     
===========================================
+ Hits       112895   150516    +37621     
- Misses     117168   201438    +84270     
- Partials     8621    16187     +7566     

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

@deepthi deepthi requested a review from maxenglander January 30, 2024 14:49
Copy link
Collaborator

@maxenglander maxenglander left a comment

Choose a reason for hiding this comment

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

Instead of the current approach, what if you:

  • Copied tabletMap (line 162), filtering out all tablets except for the one specified in opts.NewPrimaryAlias,
  • Removed the conditional check on line 173 for opts.NewPrimaryAlias,

I think that would reduce code complexity and reduce logic drift in the future when new behaviors are added to the ChooseNewPrimary path.

@deepthi
Copy link
Member

deepthi commented Jan 30, 2024

why does CodeCov say this?

Report is 81 commits behind head on main.

@GuptaManan100
Copy link
Member Author

I think that would reduce code complexity and reduce logic drift in the future when new behaviors are added to the ChooseNewPrimary path.

@deepthi @maxenglander I have made the required changes. I have chosen the approach that Deepthi pointed out, that ends up being a cleaner solution. I had to make a couple more changes to preserve the behaviour wherein we don't call findPositionAndLagForTablet when new primary has been provided but no tolerable replication lag is given.

I think the code looks good now, could you two please review it again?

Report is 81 commits behind head on main.

I have no idea why codecov says this.

Copy link
Collaborator

@maxenglander maxenglander left a comment

Choose a reason for hiding this comment

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

LGTM! Some minor comments.

go/vt/vtctl/reparentutil/planned_reparenter.go Outdated Show resolved Hide resolved
go/vt/vtctl/reparentutil/planned_reparenter.go Outdated Show resolved Hide resolved
go/vt/vtctl/reparentutil/planned_reparenter.go Outdated Show resolved Hide resolved
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.

Looks good.

@@ -114,9 +134,9 @@ func ChooseNewPrimary(
return nil, err
}

// return nothing if there are no valid tablets available
// return an error if there are no valid tablets available
Copy link
Member

Choose a reason for hiding this comment

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

💯

@GuptaManan100 GuptaManan100 merged commit 0920465 into vitessio:main Feb 4, 2024
101 of 102 checks passed
@GuptaManan100 GuptaManan100 deleted the tolerable-repl-lag branch February 4, 2024 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Cluster management Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug Report: TolerableReplicationLag not checked if the new primary is provided in PRS
3 participants