-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[vtctldserver] OnlineDDL protobuf message introduction #12195
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
Changes from all commits
f019a18
6a54395
807d5c4
804e7eb
1307cc0
a02d5d2
d2c41c9
9b81a29
abead9a
ce4c867
66129bf
90d814f
bf17773
dbddd94
85de1ce
1eeb4cf
53deee8
b299900
3381922
3dbbd40
14807cc
e423990
7a0e9dd
e22973c
26726cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,8 @@ import ( | |
| "vitess.io/vitess/go/mysql" | ||
| "vitess.io/vitess/go/vt/schema" | ||
|
|
||
| tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata" | ||
|
|
||
| "vitess.io/vitess/go/test/endtoend/cluster" | ||
| "vitess.io/vitess/go/test/endtoend/onlineddl" | ||
| "vitess.io/vitess/go/test/endtoend/throttler" | ||
|
|
@@ -221,11 +223,11 @@ func TestSchemaChange(t *testing.T) { | |
|
|
||
| testWithInitialSchema(t) | ||
| t.Run("create non_online", func(t *testing.T) { | ||
| _ = testOnlineDDLStatement(t, alterTableNormalStatement, string(schema.DDLStrategyDirect), "vtctl", "non_online", "") | ||
| _ = testOnlineDDLStatement(t, alterTableNormalStatement, "direct", "vtctl", "non_online", "") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have a helper function that translates
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably based on |
||
| }) | ||
| t.Run("successful online alter, vtgate", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, alterTableSuccessfulStatement, "gh-ost", "vtgate", "ghost_col", "") | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusComplete) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_COMPLETE) | ||
| onlineddl.CheckCancelMigration(t, &vtParams, shards, uuid, false) | ||
| onlineddl.CheckRetryMigration(t, &vtParams, shards, uuid, false) | ||
|
|
||
|
|
@@ -250,35 +252,35 @@ func TestSchemaChange(t *testing.T) { | |
| }) | ||
| t.Run("successful online alter, vtctl", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, alterTableTrivialStatement, "gh-ost", "vtctl", "ghost_col", "") | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusComplete) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_COMPLETE) | ||
| onlineddl.CheckCancelMigration(t, &vtParams, shards, uuid, false) | ||
| onlineddl.CheckRetryMigration(t, &vtParams, shards, uuid, false) | ||
| }) | ||
| t.Run("successful online alter, postponed, vtgate", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, alterTableTrivialStatement, "gh-ost -postpone-completion", "vtgate", "ghost_col", "") | ||
| // Should be still running! | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusRunning) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_RUNNING) | ||
| // Issue a complete and wait for successful completion | ||
| onlineddl.CheckCompleteMigration(t, &vtParams, shards, uuid, true) | ||
| // This part may take a while, because we depend on vreplicatoin polling | ||
| status := onlineddl.WaitForMigrationStatus(t, &vtParams, shards, uuid, normalMigrationWait, schema.OnlineDDLStatusComplete, schema.OnlineDDLStatusFailed) | ||
| status := onlineddl.WaitForMigrationStatus(t, &vtParams, shards, uuid, normalMigrationWait, tabletmanagerdatapb.OnlineDDL_COMPLETE, tabletmanagerdatapb.OnlineDDL_FAILED) | ||
| fmt.Printf("# Migration status (for debug purposes): <%s>\n", status) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusComplete) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_COMPLETE) | ||
|
|
||
| onlineddl.CheckCancelMigration(t, &vtParams, shards, uuid, false) | ||
| onlineddl.CheckRetryMigration(t, &vtParams, shards, uuid, false) | ||
| }) | ||
| t.Run("throttled migration", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, alterTableThrottlingStatement, "gh-ost --max-load=Threads_running=1", "vtgate", "ghost_col", "") | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusRunning) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_RUNNING) | ||
| onlineddl.CheckCancelMigration(t, &vtParams, shards, uuid, true) | ||
| status := onlineddl.WaitForMigrationStatus(t, &vtParams, shards, uuid, 20*time.Second, schema.OnlineDDLStatusFailed, schema.OnlineDDLStatusCancelled) | ||
| status := onlineddl.WaitForMigrationStatus(t, &vtParams, shards, uuid, 20*time.Second, tabletmanagerdatapb.OnlineDDL_FAILED, tabletmanagerdatapb.OnlineDDL_CANCELLED) | ||
| fmt.Printf("# Migration status (for debug purposes): <%s>\n", status) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusCancelled) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_CANCELLED) | ||
| }) | ||
| t.Run("failed migration", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, alterTableFailedStatement, "gh-ost", "vtgate", "ghost_col", "") | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusFailed) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_FAILED) | ||
| onlineddl.CheckCancelMigration(t, &vtParams, shards, uuid, false) | ||
| onlineddl.CheckRetryMigration(t, &vtParams, shards, uuid, true) | ||
| // migration will fail again | ||
|
|
@@ -304,47 +306,47 @@ func TestSchemaChange(t *testing.T) { | |
| }) | ||
| t.Run("Online DROP, vtctl", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, onlineDDLDropTableStatement, "gh-ost", "vtctl", "", "") | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusComplete) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_COMPLETE) | ||
| onlineddl.CheckCancelMigration(t, &vtParams, shards, uuid, false) | ||
| onlineddl.CheckRetryMigration(t, &vtParams, shards, uuid, false) | ||
| }) | ||
| t.Run("Online CREATE, vtctl", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, onlineDDLCreateTableStatement, "gh-ost", "vtctl", "online_ddl_create_col", "") | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusComplete) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_COMPLETE) | ||
| onlineddl.CheckCancelMigration(t, &vtParams, shards, uuid, false) | ||
| onlineddl.CheckRetryMigration(t, &vtParams, shards, uuid, false) | ||
| }) | ||
| t.Run("Online DROP TABLE IF EXISTS, vtgate", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, onlineDDLDropTableIfExistsStatement, "gh-ost", "vtgate", "", "") | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusComplete) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_COMPLETE) | ||
| onlineddl.CheckCancelMigration(t, &vtParams, shards, uuid, false) | ||
| onlineddl.CheckRetryMigration(t, &vtParams, shards, uuid, false) | ||
| // this table existed | ||
| checkTables(t, schema.OnlineDDLToGCUUID(uuid), 1) | ||
| }) | ||
| t.Run("Online DROP TABLE IF EXISTS for nonexistent table, vtgate", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, onlineDDLDropTableIfExistsStatement, "gh-ost", "vtgate", "", "") | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusComplete) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_COMPLETE) | ||
| onlineddl.CheckCancelMigration(t, &vtParams, shards, uuid, false) | ||
| onlineddl.CheckRetryMigration(t, &vtParams, shards, uuid, false) | ||
| // this table did not exist | ||
| checkTables(t, schema.OnlineDDLToGCUUID(uuid), 0) | ||
| }) | ||
| t.Run("Online DROP TABLE for nonexistent table, expect error, vtgate", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, onlineDDLDropTableStatement, "gh-ost", "vtgate", "", "") | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusFailed) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_FAILED) | ||
| onlineddl.CheckCancelMigration(t, &vtParams, shards, uuid, false) | ||
| onlineddl.CheckRetryMigration(t, &vtParams, shards, uuid, true) | ||
| }) | ||
| t.Run("Online CREATE no PK table, vtgate", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, noPKCreateTableStatement, "gh-ost", "vtgate", "online_ddl_create_col", "") | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusComplete) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_COMPLETE) | ||
| onlineddl.CheckCancelMigration(t, &vtParams, shards, uuid, false) | ||
| onlineddl.CheckRetryMigration(t, &vtParams, shards, uuid, false) | ||
| }) | ||
| t.Run("Fail ALTER for no PK table, vtgate", func(t *testing.T) { | ||
| uuid := testOnlineDDLStatement(t, alterTableTrivialStatement, "gh-ost", "vtgate", "", "") | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, schema.OnlineDDLStatusFailed) | ||
| onlineddl.CheckMigrationStatus(t, &vtParams, shards, uuid, tabletmanagerdatapb.OnlineDDL_FAILED) | ||
|
|
||
| expectedMessage := "No PRIMARY nor UNIQUE key found" | ||
| rs := onlineddl.ReadMigrations(t, &vtParams, uuid) | ||
|
|
@@ -405,8 +407,8 @@ func testOnlineDDLStatement(t *testing.T, alterStatement string, ddlStrategy str | |
| strategySetting, err := schema.ParseDDLStrategy(ddlStrategy) | ||
| assert.NoError(t, err) | ||
|
|
||
| if !strategySetting.Strategy.IsDirect() { | ||
| status := onlineddl.WaitForMigrationStatus(t, &vtParams, shards, uuid, normalMigrationWait, schema.OnlineDDLStatusComplete, schema.OnlineDDLStatusFailed) | ||
| if !strategySetting.IsDirect() { | ||
| status := onlineddl.WaitForMigrationStatus(t, &vtParams, shards, uuid, normalMigrationWait, tabletmanagerdatapb.OnlineDDL_COMPLETE, tabletmanagerdatapb.OnlineDDL_FAILED) | ||
| fmt.Printf("# Migration status (for debug purposes): <%s>\n", status) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a helper function to simplify
strings.ToLower(tabletmanagerdatapb.OnlineDDL_Strategy_name[int32(...)])? This kind of logic recurs a few times in the code and I find it difficult to parse.