Skip to content

workflow: validate VReplication config overrides before changing workflows - #22182

Open
Shubhamnish1030 wants to merge 3 commits into
vitessio:mainfrom
Shubhamnish1030:workflow-config-overrides-validation
Open

Shubhamnish1030 wants to merge 3 commits into
vitessio:mainfrom
Shubhamnish1030:workflow-config-overrides-validation

Conversation

@Shubhamnish1030

@Shubhamnish1030 Shubhamnish1030 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Description

The values of --config-overrides were only parsed on the target tablets, after the stream rows had been written:

  • a failed MoveTables create left the target tables and Stopped streams behind as a workflow that MoveTables cancel could not remove, because stopping it re-reads the invalid options;
  • a failed Workflow update stored the invalid options and left the streams without a controller, while _vt.vreplication still showed them Running with an empty message.

This PR checks the overrides with NewVReplicationConfig, the same parser the tablets use, at the start of MoveTables/Migrate create, Reshard create, Materialize and Workflow update, and returns an INVALID_ARGUMENT error before anything is changed, like the other request checks in these functions. Workflow update validates the trimmed values, as the tablets trim them before storing, so a blank value, which removes an override, is still accepted. Valid overrides behave as before.

Motivation

How do you use Vitess? (pick one)

  • In production
  • In staging or development
  • Evaluating it
  • I don't use Vitess

Did you run this change against a real Vitess deployment? Yes, on a local examples/local cluster (MySQL 8.4.11, etcd 3.6.7), moving commerce.product into a two-shard demo keyspace. I swapped only vtctld between main (84d5f2d) and this branch (6306aa9, and 130c087 for the trimmed update values).

With vtctld from main:

  • MoveTables create ... --config-overrides vreplication-copy-phase-duration=notaduration failed on the tablets, but left demo.product, a Stopped stream with the invalid config on both shards, and a wf_cfg workflow that MoveTables cancel could not remove (failed to stop workflow wf_cfg on shard demo/-80: ... failed to process config options). It could only be removed by first running Workflow update with a valid value.
  • On a running workflow, Workflow update with the same override failed but stored the invalid options, and _vt.vreplication still showed the streams as Running with an empty message. 10 rows inserted on the source afterwards did not reach the target until a later update set a valid value.

With vtctld from this branch, both commands fail with invalid config overrides: invalid value for vreplication-copy-phase-duration: notaduration and change nothing: after the failed create there is no workflow, no _vt.vreplication row and no demo.product; after the failed update the options are unchanged and the 10 inserted rows replicate. A valid override (=1h) and cancel work as before.

Related Issue(s)

Fixes #22176

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches (not proposing one)
  • If this change is to be back-ported to previous releases, a justification is included in the PR description (no backport: the vtctld-side check changes which requests are accepted during upgrades, see Deployment Notes)
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI? (locally; CI pending)
  • Documentation was added or is not required (not required)

Tests:

  • TestConfigOverridesValidatedBeforeWorkflowChanges (go/vt/vtctl/workflow/server_test.go): an invalid value and an unknown flag are rejected with INVALID_ARGUMENT by MoveTablesCreate, ReshardCreate, Materialize and WorkflowUpdate. The test records the tablet RPCs that change schema or streams and asserts that none is made, so it fails if the overrides are only checked after a tablet has been changed. An update with valid, padded (" 1h ") and blank (removing) values still reaches the tablets. Fails on main, passes with this change; go test ./go/vt/vtctl/workflow/... ./go/vt/vtctl/grpcvtctldserver/ ./go/cmd/vtctldclient/command/vreplication/... passes.

Deployment Notes

Invalid --config-overrides values are now rejected by vtctld with INVALID_ARGUMENT before any change, instead of failing on the tablets afterwards.

Version skew between vtctld and the tablets during an upgrade:

  • vttablet newer than vtctld: vtctld now checks the keys itself, so an override key that only the newer vttablet release knows is rejected until vtctld runs that release too. A key already has to be known by vtctldclient and by the source vstreamer, so this only adds VTAdmin and direct gRPC callers, and a newer vtctldclient talking to an older vtctld.
  • vtctld newer than vttablet: vtctld accepts keys that the older tablets do not know, so the check does not protect them. For example vstream-memory-bounds and max-row-json-bytes are known on main but not on release-24.0: a v25 vtctld passes them, and v24 tablets still store them and then fail as described in Bug Report: an invalid --config-overrides value leaves a workflow that cannot be cancelled (create) or silently stops its streams (update) #22176. "Before anything is changed" therefore holds only when the tablets know every key that vtctld does. Validating the options in the tablet's CreateVReplicationWorkflow, and the merged options in UpdateVReplicationWorkflow, before the write would close this gap in a later release.

AI Disclosure

AI assistance: this PR was drafted with Claude Code. I found the problem while probing Workflow update on a local cluster, traced the partial writes to the tablet-side parsing, and ran the tests locally.

…flows

The values of --config-overrides were only parsed on the target tablets,
after the stream rows had been written. A failed MoveTables create left the
target tables and Stopped streams behind as a workflow that MoveTables
cancel could not remove (stopping it re-reads the invalid options), and a
failed Workflow update stored the invalid options and left the streams
without a controller while _vt.vreplication still showed them Running.

Check the overrides with NewVReplicationConfig, as the tablets do, at the
start of MoveTables/Migrate create, Reshard create, Materialize and Workflow
update, and return INVALID_ARGUMENT before anything is changed.

Signed-off-by: Shubham Chandrawanshi <179670574+Shubhamnish1030@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 28, 2026 06:48
@github-actions github-actions Bot added this to the v25.0.0 milestone Nov 28, 2026
@vitess-bot vitess-bot Bot added NeedsWebsiteDocsUpdate What it says NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work 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 Nov 28, 2026
@vitess-bot

vitess-bot Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

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.

🟡 Changes recommended

Override validation introduces upgrade-order incompatibility and rejects previously valid whitespace-normalized updates, while the tests do not verify that invalid requests leave workflow state unchanged.

3 open issues
What changed in this PR

This PR addresses #22176 by validating VReplication config overrides in vtctld before workflow changes, preventing invalid options from leaving partially created workflows or stopping replication.

Changes:

  • Adds a shared validator using the tablet-side parser and returning INVALID_ARGUMENT.
  • Applies validation to MoveTables/Migrate, Reshard, Materialize, and Workflow update.
  • Adds tests for invalid values, unknown keys, and acceptance of valid and empty values.
File Description
go/​vt/​vtctl/​workflow/​utils.go Adds shared config-override validation.
go/​vt/​vtctl/​workflow/​server.go Validates overrides at workflow entry points.
go/​vt/​vtctl/​workflow/​server_test.go Adds validation regression tests.

Review effort: Balanced

Comment thread go/vt/vtctl/workflow/server.go Resolved
Comment thread go/vt/vtctl/workflow/server_test.go Resolved
Comment on lines +665 to +666
if _, err := vttablet.NewVReplicationConfig(overrides); err != nil {
return vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "invalid config overrides: %v", err)

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.

This is a fair point, and it is a trade-off I'd like a maintainer's view on.

The restriction is narrow: it only applies while vttablet runs a newer release than vtctld, and only to an override key that was added in that newer release. A key that both releases know is unaffected, and upgrading vtctld removes the restriction.

I see two ways to handle it:

  1. Keep rejecting unknown keys in vtctld (the PR as it is). A mistyped key is rejected before anything is written, which is the full fix for Bug Report: an invalid --config-overrides value leaves a workflow that cannot be cancelled (create) or silently stops its streams (update) #22176. The cost is the restriction above.
  2. Only reject invalid values for keys vtctld knows, and pass unknown keys through to the tablets as today. This keeps mixed-version behaviour exactly as it is now. The cost is that an unknown or mistyped key still fails on the tablets after the write, so that case of Bug Report: an invalid --config-overrides value leaves a workflow that cannot be cancelled (create) or silently stops its streams (update) #22176 stays (a MoveTables create with a mistyped key still leaves a workflow that cancel cannot remove).

I lean towards 1, since it only matters while vttablet is newer than vtctld and the failure is a clear error with nothing changed, but I'm happy to switch to 2, or to make cancel tolerate invalid stored options as a follow-up so that 2 is no longer stuck. @mattlord, which would you prefer?

…s in the test

The tablets trim the values of a Workflow update and treat a blank value as
the removal of that override, so validating the raw values rejected updates
such as " 1h " that were accepted before. Validate the trimmed values, which
are the ones the tablets store.

The test now records the tablet RPCs that change schema or streams and
asserts that none is made for an invalid override, so it fails if the
overrides are only checked after a tablet has been changed. It also checks
that an update with padded and blank values still reaches the tablets.

Signed-off-by: Shubham Chandrawanshi <179670574+Shubhamnish1030@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 28, 2026 07:04

Copilot AI left a comment

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.

🔵 Needs a closer look

The new test fixture uses defer env.close() instead of the required t.Cleanup(env.close), so teardown is not registered with the test lifecycle.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Low severity Use test-scoped cleanup for fixture teardown

go/​vt/​vtctl/​workflow/​server_test.go:3840

Register this fixture cleanup with t.Cleanup(env.close) rather than defer env.close(). New tests are required to use test-scoped cleanup so teardown follows the testing lifecycle, including completion of subtests.

1 resolved since last review

Review effort: Balanced

Compare the routing rules, the shard routing rules and the vschema and
shards of both keyspaces before and after each rejected request, so that
the test also fails if a topology record is written before the overrides
are checked. Register the fixture teardown with t.Cleanup.

Signed-off-by: Shubham Chandrawanshi <179670574+Shubhamnish1030@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 28, 2026 07:12

Copilot AI left a comment

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.

🔵 Needs a closer look

The release-dependent vtctld key whitelist may reject overrides supported by newer tablets during rolling upgrades, and the supplied single-version tests do not establish adjacent-major compatibility.

1 open issue
1 resolved since last review

Review effort: Balanced

@mattlord mattlord left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix and the thorough repro!

  1. I think that option 1, rejecting unknown keys in vtctld as the PR does now, is the right call for the open compatibility thread. A key already has to be known by every component in the path today: vtctldclient's ParseConfigOverrides rejects any key the client doesn't know (go/cmd/vtctldclient/command/vreplication/common/utils.go:243), and the target forwards all of the overrides to the source's vstreamer, which rejects unknown keys too (go/vt/vttablet/tabletserver/vstreamer/utils.go:34). The new restriction only adds VTAdmin and direct gRPC callers, and a newer vtctldclient talking to an older vtctld, and it fails with a clear INVALID_ARGUMENT before anything is written. Upgrading vtctld lifts it.

  2. I think that we should also mention the other version skew in the Deployment Notes. When vtctld is newer than the tablets, its parser accepts keys that the older tablets don't know: vstream-memory-bounds and max-row-json-bytes are on main but not in release-24.0's parser. So a v25 vtctld lets them through validateConfigOverrides (go/vt/vtctl/workflow/utils.go:661), and v24 tablets still store them and then fail in processWorkflowOptions (go/vt/vttablet/tabletmanager/rpc_vreplication.go:630, go/vt/vttablet/tabletmanager/vreplication/controller.go:124), which is the #22176 behavior, the same as on main. "Before anything is changed" therefore holds only when the tablets know every key that vtctld does. A follow-up could validate the options in the tablet's CreateVReplicationWorkflow, and the merged options in UpdateVReplicationWorkflow, before the write, which would close this gap for later releases.

Otherwise this looks good to me.

@mattlord
mattlord requested a review from a team November 28, 2026 15:21
@codecov

codecov Bot commented Nov 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.92%. Comparing base (70c7a72) to head (d9059e3).
⚠️ Report is 849 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main   #22182       +/-   ##
===========================================
+ Coverage   69.67%   78.92%    +9.25%     
===========================================
  Files        1614      122     -1492     
  Lines      216793    23569   -193224     
===========================================
- Hits       151044    18603   -132441     
+ Misses      65749     4966    -60783     
Flag Coverage Δ
partial 78.92% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@Shubhamnish1030

Copy link
Copy Markdown
Contributor Author

Thanks for the review @mattlord! I've kept option 1 and added both directions of the version skew to the Deployment Notes, including the newer-vtctld / older-tablet case with vstream-memory-bounds and max-row-json-bytes (I checked that release-24.0 has neither key). I'm happy to take the tablet-side validation in CreateVReplicationWorkflow / UpdateVReplicationWorkflow as a follow-up if that's useful.

The vtgate_gen4 failure ran 0 tests (package selection error in the runner), so it looks unrelated; a re-run should clear it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 Type: Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: an invalid --config-overrides value leaves a workflow that cannot be cancelled (create) or silently stops its streams (update)

3 participants