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

OnlineDDL: reject duplicate UUID with different migration_context #9637

Merged

Conversation

shlomi-noach
Copy link
Contributor

@shlomi-noach shlomi-noach commented Feb 6, 2022

Description

Followup to #9325. In this PR we reject a migration if submitted with same UUID and different migration_context.

As reminder, the user is allowed to supply their own migration UUIDs via vtctl ApplySchema -uuid_list='...'. This functionality is used to allow the user control and idempotency over their migrations.

UUID is a unique migration identifier. It is impossible to have any two migrations on same shard with same UUID. Hence, when one submits -uuid_list=... with an already existing UUID, their submission does not create a new migration. However, it is then also reasonable to expect that the user provides -migration_context. If the same migration is submitted twice or more, with same UUID and same migration_context, that is fine. The newer submissions are silently ignored, and this is a desired behavior that allows idempotency.

However, if the new submission uses a different migration_context (either because the user has specified one, that is different from the original one; or the user has specified none at all, in which case vtctl generates a random, unique value), then we consider this as an unintentional duplication, and as of this PR we return an error.

Here is a valid resubmission:

$ vtctlclient ApplySchema -skip_preflight -ddl_strategy='online' -migration_context="1222-2342342-423423-42" -uuid_list="4b25f49c_8709_11ec_9f54_0a43f95f28a5" -sql "alter table customer engine=innodb" commerce
4b25f49c_8709_11ec_9f54_0a43f95f28a5
$ vtctlclient ApplySchema -skip_preflight -ddl_strategy='online' -migration_context="1222-2342342-423423-42" -uuid_list="4b25f49c_8709_11ec_9f54_0a43f95f28a5" -sql "alter table customer engine=innodb" commerce
4b25f49c_8709_11ec_9f54_0a43f95f28a5

Here is an invalid one:

$ vtctlclient ApplySchema -skip_preflight -ddl_strategy='online' -uuid_list="4b25f49c_8709_11ec_9f54_0a43f95f28a6" -sql "alter table customer engine=innodb" commerce
4b25f49c_8709_11ec_9f54_0a43f95f28a6
$ vtctlclient ApplySchema -skip_preflight -ddl_strategy='online' -uuid_list="4b25f49c_8709_11ec_9f54_0a43f95f28a6" -sql "alter table customer engine=innodb" commerce
E0206 04:59:15.849989  800011 main.go:67] E0206 04:59:15.849210 vtctl.go:3282] schema change failed, ExecuteResult: {
  "FailedShards": [
    {
      "Shard": "0",
      "Err": "rpc error: code = Unknown desc = TabletManager.ExecuteQuery on zone1-0000000100 error: rpc error: code = FailedPrecondition desc = migration rejected: found migration 4b25f49c_8709_11ec_9f54_0a43f95f28a6 with different context: vtctl:84ee1103-8709-11ec-9f54-0a43f95f28a3 than submmitted migration's context: vtctl:88a0f8b4-8709-11ec-9f54-0a43f95f28a3: rpc error: code = FailedPrecondition desc = migration rejected: found migration 4b25f49c_8709_11ec_9f54_0a43f95f28a6 with different context: vtctl:84ee1103-8709-11ec-9f54-0a43f95f28a3 than submmitted migration's context: vtctl:88a0f8b4-8709-11ec-9f54-0a43f95f28a3"
    }
  ],
...

Related Issue(s)

Checklist

  • Should this PR be backported?
  • Tests were added or are not required
  • Documentation was added or is not required

cc @dbussink @fatih @mavenraven

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
@shlomi-noach shlomi-noach added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: Query Serving release notes labels Feb 6, 2022
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Comment on lines 18 to 19
- `vtctl ApplySchema -uuid_list='...'` now rejects a migration if an existing migration has the same UUID but with different `migration_context`.

Copy link
Member

Choose a reason for hiding this comment

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

Wrong file? This is the 10.0.4 release notes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wrong file indeed

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
@shlomi-noach
Copy link
Contributor Author

The test Upgrade Downgrade Testing Query Serving / Get latest release (pull_request) keeps failing, this is unrelated to my PR.

Excerpt:

2022-02-08T09:59:09.6952407Z === RUN   TestNewUnshardedTable
2022-02-08T09:59:09.6973079Z     st_unsharded_test.go:103: 
2022-02-08T09:59:09.6974386Z         	Error Trace:	st_unsharded_test.go:103
2022-02-08T09:59:09.6975069Z         	Error:      	Not equal: 
2022-02-08T09:59:09.6985687Z         	            	expected: "[[VARCHAR(\"dual\")] [VARCHAR(\"main\")]]"
2022-02-08T09:59:09.6986286Z         	            	actual  : "[[VARCHAR(\"dual\")]]"
2022-02-08T09:59:09.6986575Z         	            	
2022-02-08T09:59:09.6987632Z         	            	Diff:
2022-02-08T09:59:09.6988374Z         	            	--- Expected
2022-02-08T09:59:09.6988897Z         	            	+++ Actual
2022-02-08T09:59:09.6990030Z         	            	@@ -1 +1 @@
2022-02-08T09:59:09.6991027Z         	            	-[[VARCHAR("dual")] [VARCHAR("main")]]
2022-02-08T09:59:09.6996097Z         	            	+[[VARCHAR("dual")]]
2022-02-08T09:59:09.6996482Z         	Test:       	TestNewUnshardedTable
2022-02-08T09:59:09.6996888Z --- FAIL: TestNewUnshardedTable (0.00s)
2022-02-08T09:59:09.6997116Z FAIL
2022-02-08T09:59:13.8529964Z FAIL	vitess.io/vitess/go/test/endtoend/vtgate/schematracker/unsharded	10.295s
2022-02-08T09:59:13.8584939Z FAIL
2022-02-08T09:59:13.8740160Z 2022/02/08 09:59:13 local.vtgate_schematracker_unsharded: saving test output to _test/20220208-095437.23387/local.vtgate_schematracker_unsharded-1.1.log
2022-02-08T09:59:13.8744938Z 2022/02/08 09:59:13 local.vtgate_schematracker_unsharded: FAILED (try 1/1) in 12s: exit status 1
2022-02-08T09:59:13.8748189Z 2022/02/08 09:59:13 local.vtgate_schematracker_unsharded: retry limit exceeded
2022-02-08T09:59:13.8749341Z 2022/02/08 09:59:13 local.vtgate_vschema: running (try 1/1)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants