Documenting new Online DDL via VReplication, 'online' strategy#718
Documenting new Online DDL via VReplication, 'online' strategy#718shlomi-noach merged 6 commits intoprodfrom
Conversation
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
|
Deploy preview for vitess ready! Built with commit f7ef197 |
|
|
||
| #### Load | ||
|
|
||
| - `pt-online-schema-change` uses triggers to propagate changes. This method is traditionally known to generate high load on the server. Both VReplication and `gh-ost` tail the binary logs to capture changes, and thi sapproach is known to be more lightweight. |
There was a problem hiding this comment.
| - `pt-online-schema-change` uses triggers to propagate changes. This method is traditionally known to generate high load on the server. Both VReplication and `gh-ost` tail the binary logs to capture changes, and thi sapproach is known to be more lightweight. | |
| - `pt-online-schema-change` uses triggers to propagate changes. This method is traditionally known to generate high load on the server. Both VReplication and `gh-ost` tail the binary logs to capture changes, and this approach is known to be more lightweight. |
|
|
||
| To be able to run online schema migrations via `gh-ost`: | ||
|
|
||
| - If you're on Linux/amd64 architecture, and on `glibc` `2.3` or similar, there are no further dependencies. Vitess comes with a built-in `gh-ost` binary, that is compatible with your system. |
There was a problem hiding this comment.
Should it be mentioned that this is true of the Vitess Docker images on Dockerhub?
| - `set @@ddl_strategy='gh-ost --max-load Threads_running=200 --critical-load Threads_running=500 --critical-load-hibernate-seconds=60 --default-retries=512';` | ||
| - `vtctl -ddl_strategy "gh-ost --allow-nullable-unique-key --chunk-size 200" ApplySchema ...` | ||
|
|
||
| Do not override the following flags: `alter, database, table, execute, max-lag, force-table-names, serve-socket-file, hooks-path, hooks-hint-token, panic-flag-file`. |
There was a problem hiding this comment.
Can you add more detail here? Will something bad happen if you do? Or will Vitess reject the request? Or will Vitess silently drop your flags?
There was a problem hiding this comment.
Good point! Added.
|
|
||
| #### Setup | ||
|
|
||
| - Vreplication is part of Vitess |
There was a problem hiding this comment.
| - Vreplication is part of Vitess | |
| - VReplication is part of Vitess |
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
|
@jmoldow thank you for the review, I've addressed your comments (without technically "accepting changes" because of signoff issue). |
|
This is fantastic documentation.
Is the schema introspected when you call alter and rejects tables with FKs? Will it silently fail during the alter? Is there a recommendation for removing them before the alter and adding them back after? |
In my understanding this leads to foreign-key broken integrity. Something will have happened during the migration that violates some foreign key constraint. "child"-side this may be worked around, "parent"-side ther is no solution that I'm aware of. I've been at this for years and years, and I can't see a way out, unfortunately. |
There was a problem hiding this comment.
Beautifully written as always.
You may address the feedback in a separate PR if you prefer to do so. Mainly around incorporating changes from vitessio/vitess#7603, and a few nits/typos.
| - `pt-online-schema-change` tool installed and is executable | ||
| - Perl `libdbi` and `libdbd-mysql` modules installed. e.g. on Debian/Ubuntu, `sudo apt-get install libdbi-perl libdbd-mysql-perl` | ||
| - Run `vttablet` with `-pt-osc-path=/full/path/to/pt-online-schema-change` flag. | ||
|
|
There was a problem hiding this comment.
This section should be updated since we merged vitessio/vitess#7603.
There was a problem hiding this comment.
Clarified that pt-osc and dependencies are pre-installed in Vitess Docker images
|
|
||
| ### Comparing the options | ||
|
|
||
| There are pros and cons to using either of the strategies. Some notable differences: |
There was a problem hiding this comment.
Nit: there are more than two options, so it should be "any" or "each" instead of "either".
|
|
||
| - VReplication is part of Vitess | ||
| - A `gh-ost` binary is embedded within the Vitess binary, compatible with `glibc 2.3` and `Linux/amd64`. The user may choose to use their own `gh-ost` binary, configured with `-gh-ost-path`. | ||
| - `pt-online-schema-change` is not included in Vitess, and the user needs to set it up on tablet hosts. |
There was a problem hiding this comment.
Clarified that pt-osc and dependencies are pre-installed in Vitess Docker images
| - The value `"pt-osc"` instructs Vitess to run an `ALTER TABLE` online DDL via `pt-online-schema-change`. | ||
| - You may specify arguments for your tool of choice, e.g. `"gh-ost --max-load Threads_running=200"`. Details follow. | ||
|
|
||
| `CREATE` and `DROP` statements run in the same way for `"online"`, `"gh-ost"` and `"pt-osc"` strategies, andwe consider them all to be _online_. |
| - in MySQL pre `8.0.23`, a `DROP TABLE` operation can be dangerous in production as it commonly locks the buffer pool for a substantial period. | ||
|
|
||
| Artifact tables are identifiable via `SELECT artifacts FROM _vt.schema_migrations` in a `VExec` command, see below. | ||
| The tables are kept for 24 hours since migration completion. Vitess automatically cleans up those tables as soon as a migration completes (either successful or failed). You will normally not need to do anything. |
There was a problem hiding this comment.
| The tables are kept for 24 hours since migration completion. Vitess automatically cleans up those tables as soon as a migration completes (either successful or failed). You will normally not need to do anything. | |
| The tables are kept for 24 hours after migration completion. Vitess automatically cleans up those tables as soon as a migration completes (either successful or failed). You will normally not need to do anything. |
| ## Table cleanup | ||
|
|
||
| Both `gh-ost` and `pt-online-schema-change` leave artifacts behind. Whether successful or failed, either the original table or the _ghost_ table are left still populated at the end of the migration. Vitess explicitly configures both tools to not drop those tables. The reason is that in MySQL, a `DROP TABLE` operation can be dangerous in production as it commonly locks the buffer pool for a substantial period. | ||
| All `ALTER` strategies leave artifacts behind. Whether successful or failed, either the original table or the _ghost_ table are left still populated at the end of the migration. Vitess explicitly makes sure the tables are not dropped at the end of the migration. This is for two reasons: |
There was a problem hiding this comment.
| All `ALTER` strategies leave artifacts behind. Whether successful or failed, either the original table or the _ghost_ table are left still populated at the end of the migration. Vitess explicitly makes sure the tables are not dropped at the end of the migration. This is for two reasons: | |
| All `ALTER` strategies leave artifacts behind. Whether successful or failed, either the original table or the _ghost_ table is left still populated at the end of the migration. Vitess explicitly makes sure the tables are not dropped at the end of the migration. This is for two reasons: |
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
This documents the changes in the now-merged PR vitessio/vitess#7419:
onlinestrategy