You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
workflow: validate VReplication config overrides before changing workflows - #22182
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.
"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>
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
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.
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.
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 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>
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.
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>
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.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix and the thorough repro!
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.
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.
✅ 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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The values of
--config-overrideswere only parsed on the target tablets, after the stream rows had been written:MoveTables createleft the target tables andStoppedstreams behind as a workflow thatMoveTables cancelcould not remove, because stopping it re-reads the invalid options;Workflow updatestored the invalid options and left the streams without a controller, while_vt.vreplicationstill showed themRunningwith an empty message.This PR checks the overrides with
NewVReplicationConfig, the same parser the tablets use, at the start ofMoveTables/Migratecreate,Reshardcreate,MaterializeandWorkflow update, and returns anINVALID_ARGUMENTerror before anything is changed, like the other request checks in these functions.Workflow updatevalidates 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)
Did you run this change against a real Vitess deployment? Yes, on a local
examples/localcluster (MySQL 8.4.11, etcd 3.6.7), movingcommerce.productinto a two-sharddemokeyspace. I swapped only vtctld betweenmain(84d5f2d) and this branch (6306aa9, and 130c087 for the trimmed update values).With vtctld from
main:MoveTables create ... --config-overrides vreplication-copy-phase-duration=notadurationfailed on the tablets, but leftdemo.product, aStoppedstream with the invalid config on both shards, and awf_cfgworkflow thatMoveTables cancelcould not remove (failed to stop workflow wf_cfg on shard demo/-80: ... failed to process config options). It could only be removed by first runningWorkflow updatewith a valid value.Workflow updatewith the same override failed but stored the invalid options, and_vt.vreplicationstill showed the streams asRunningwith 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: notadurationand change nothing: after the failed create there is no workflow, no_vt.vreplicationrow and nodemo.product; after the failed update the options are unchanged and the 10 inserted rows replicate. A valid override (=1h) andcancelwork as before.Related Issue(s)
Fixes #22176
Checklist
Tests:
TestConfigOverridesValidatedBeforeWorkflowChanges(go/vt/vtctl/workflow/server_test.go): an invalid value and an unknown flag are rejected withINVALID_ARGUMENTbyMoveTablesCreate,ReshardCreate,MaterializeandWorkflowUpdate. 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 onmain, passes with this change;go test ./go/vt/vtctl/workflow/... ./go/vt/vtctl/grpcvtctldserver/ ./go/cmd/vtctldclient/command/vreplication/...passes.Deployment Notes
Invalid
--config-overridesvalues are now rejected by vtctld withINVALID_ARGUMENTbefore any change, instead of failing on the tablets afterwards.Version skew between vtctld and the tablets during an upgrade:
vstream-memory-boundsandmax-row-json-bytesare known onmainbut not onrelease-24.0: a v25 vtctld passes them, and v24 tablets still store them and then fail as described in Bug Report: an invalid--config-overridesvalue 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'sCreateVReplicationWorkflow, and the merged options inUpdateVReplicationWorkflow, 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 updateon a local cluster, traced the partial writes to the tablet-side parsing, and ran the tests locally.