Skip to content

vtorc: add support for dynamic enable/disable of ERS by keyspace/shard#17985

Merged
timvaillancourt merged 42 commits intovitessio:mainfrom
timvaillancourt:vtorc-ks-topo-config
Sep 3, 2025
Merged

vtorc: add support for dynamic enable/disable of ERS by keyspace/shard#17985
timvaillancourt merged 42 commits intovitessio:mainfrom
timvaillancourt:vtorc-ks-topo-config

Conversation

@timvaillancourt
Copy link
Copy Markdown
Contributor

@timvaillancourt timvaillancourt commented Mar 18, 2025

Description

This PR adds support for ERS to be enabled/disabled in VTOrc dynamically by keyspace or keyspace/shard using the topo

Summary:

  • New vtctld client/server RPCs:
    • SetVtorcEmergencyReparent [--enable|-e] [--disable|-d] <keyspace> <shard>
    • Existing GetKeyspace and GetShard can be used to read the written record
  • New VTOrc stat (EmergencyReparentShardDisabled) to track ERS-disabled shards
  • VTOrc now:
    • Fetch/stores the disable_emergency_reparent tinyint field in the vitess_keyspace and vitess_shard tables
    • Considers the keyspace or shard-level ERS-disabled state at recovery time
tim@Tims-MacBook-Pro vitess % ./bin/vtctldclient SetVtorcEmergencyReparent --help 2>&1 | head -12 
Enable/disables the use of EmergencyReparentShard in VTOrc recoveries for a given keyspace or keyspace/shard.

Usage:
  vtctldclient SetVtorcEmergencyReparent [--enable|-e] [--disable|-d] <keyspace> <shard>

Aliases:
  SetVtorcEmergencyReparent, setvtorcemergencyreparent

Flags:
  -e, --enable    Enable the use of EmergencyReparentShard in recoveries.
  -d, --disable   Disable the use of EmergencyReparentShard in recoveries.
  -h, --help      help for SetVtorcEmergencyReparent

Related Issue(s)

#17988

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

@timvaillancourt timvaillancourt added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: VTOrc Vitess Orchestrator integration labels Mar 18, 2025
@timvaillancourt timvaillancourt self-assigned this Mar 18, 2025
@vitess-bot
Copy link
Copy Markdown
Contributor

vitess-bot bot commented Mar 18, 2025

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 Mar 18, 2025
@github-actions github-actions bot added this to the v22.0.0 milestone Mar 18, 2025
@timvaillancourt timvaillancourt removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Mar 18, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 18, 2025

Codecov Report

❌ Patch coverage is 34.80176% with 148 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.50%. Comparing base (1baf02b) to head (4ea4fc4).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtorc/logic/topology_recovery.go 0.00% 52 Missing ⚠️
go/vt/vtctl/grpcvtctldserver/server.go 0.00% 49 Missing ⚠️
go/cmd/vtctldclient/command/topology.go 14.28% 24 Missing ⚠️
go/vt/vtorc/logic/tablet_discovery.go 39.13% 14 Missing ⚠️
go/vt/vtctl/grpcvtctldclient/client_gen.go 0.00% 5 Missing ⚠️
go/vt/topotools/keyspace.go 50.00% 2 Missing ⚠️
go/vt/vtctl/localvtctldclient/client_gen.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17985      +/-   ##
==========================================
- Coverage   67.52%   67.50%   -0.02%     
==========================================
  Files        1607     1607              
  Lines      263338   263518     +180     
==========================================
+ Hits       177812   177892      +80     
- Misses      85526    85626     +100     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@timvaillancourt timvaillancourt added Component: vtctldclient and removed NeedsIssue A linked issue is missing for this Pull Request labels Mar 19, 2025
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
@timvaillancourt
Copy link
Copy Markdown
Contributor Author

@shlomi-noach thanks for the review! I believe the code and changelog suggestions are now addressed 👍

Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
@shlomi-noach
Copy link
Copy Markdown
Contributor

@timvaillancourt I see more traffic on this PR, please let us know when it is ready for final review.

@timvaillancourt
Copy link
Copy Markdown
Contributor Author

@timvaillancourt I see more traffic on this PR, please let us know when it is ready for final review.

@shlomi-noach 👋 yes, this should be ready for another pass of reviews now. Thanks!

Comment on lines +175 to +176
utils.WaitForSuccessfulRecoveryCount(t, vtOrcProcess, logic.RecoverDeadPrimaryRecoveryName, keyspace.Name, shard0.Name, 0)
utils.WaitForSuccessfulERSCount(t, vtOrcProcess, keyspace.Name, shard0.Name, 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is tricky. We wait for something to not happen and thus we provide 0 for expected count. But if you look at the code for utils.WaitForSuccessfulRecoveryCount and utils.WaitForSuccessfulERSCount, these functions just loop with timeout until they reach requested value, which is 0, which means they will exit immediately with success code.

Point being, if a failover was to happen, we'd still exit immediately, and this is wrong. I think in this case we need to add an imposed Sleep of a few seconds (you call the number) before calling these functions.

Or, otherwise, find a more formal way of knowing for sure that the recovery was ignored. But Sleep should be fine.

Copy link
Copy Markdown
Contributor Author

@timvaillancourt timvaillancourt Sep 1, 2025

Choose a reason for hiding this comment

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

@shlomi-noach great point, I missed that! 👍. Yes, a sleep would work

Another way to solve this would be to wait for another metric: I'm thinking the "# of recoveries" counter, to increase for the DeadPrimary recovery AND only then should the logic check if the desired value was reached

An alternative idea, which I pondered adding in this PR, was a "# of ERS-recoveries skipped" metric

I think I'll try this 2-dimensional metrics check and see where it goes! If a sleep approach is necessary, that's an option too

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm thinking the "# of recoveries"

Wouldn't that have the same behavior? You want that number to not incrase so the only way to check that would be to wait/sleep?

"# of ERS-recoveries skipped" metric

That would be good indeed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shlomi-noach I've updated the e2e test to wait for the RecoverDeadPrimary recovery to be skipped, using a new metric: SkippedRecoveries

Once we know RecoverDeadPrimary was skipped, it should be safe to check for 0 for the stats you originally pointed out. Let me know how it looks! 🙇

Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
@timvaillancourt timvaillancourt merged commit 982ad84 into vitessio:main Sep 3, 2025
106 of 107 checks passed
@timvaillancourt timvaillancourt deleted the vtorc-ks-topo-config branch October 1, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: vtctldclient Component: VTOrc Vitess Orchestrator integration Type: Enhancement Logical improvement (somewhere between a bug and feature)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: dynamic enable/disable of ERS by keyspace in VTOrc

7 participants