-
Notifications
You must be signed in to change notification settings - Fork 208
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
Docs: INSTANT
DDL and RANGE PARTITIONING
support for managed schema migrations
#1899
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9f6aa54
document '--prefer-instant-ddl' DDL strategy flag
shlomi-noach e6d43ac
clarify removal of old table format
shlomi-noach c732d86
fix ordering of schema change pages
shlomi-noach edaa628
preemptively add link to instant DDL page
shlomi-noach 5e64133
preemptively add more link to instant DDL page
shlomi-noach a8451bf
Adding INSTANT DDL docs for v22
shlomi-noach 4b9a4cd
INSTANT DDL in advanced usage
shlomi-noach b1cac39
formatting
shlomi-noach 1f0f429
add notes and exceptions
shlomi-noach be4e02b
partitioning notes
shlomi-noach 256f165
instant DDL docs for older versions
shlomi-noach d11d212
typo
shlomi-noach 42ed757
fix excessive text
shlomi-noach e28b3ca
remove /8.0/ from urls
shlomi-noach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
content/en/docs/19.0/user-guides/schema-changes/concurrent-migrations.md
This file contains 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
This file contains 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
This file contains 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
88 changes: 88 additions & 0 deletions
88
content/en/docs/19.0/user-guides/schema-changes/instant-ddl-migrations.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
--- | ||
title: INSTANT DDL migrations | ||
weight: 15 | ||
aliases: ['/docs/user-guides/schema-changes/instant-ddl-migrations/'] | ||
--- | ||
|
||
MySQL's [INSTANT DDL](https://dev.mysql.com/doc/refman/en/innodb-online-ddl-operations.html) is accessible in both unmanaged and managed vitess migrations. | ||
|
||
`INSTANT` DDL refers to `ALTER TABLE ... ALGORITHM=INSTANT` which runs near-instantaneously, though some locking is still witnessed in heavy workloads. It is limited to a subset of operations. The [documentation](https://dev.mysql.com/doc/refman/en/innodb-online-ddl-operations.html) lists the general limitations but does not cover the precise range of scenarios. | ||
|
||
A common naive approach to using `INSTANT` DDL is to optimistically attempt an `ALTER TABLE ... ALGORITHM=INSTANT`, and if that turns to be unsupported by `INSTANT` DDL, resort to standard `ALTER TABLE`. | ||
|
||
## INSTANT DDL in unmanaged schema changes | ||
|
||
A user may thus submit an `ALTER TABLE ... ALGORITHM=INSTANT` migration via `ApplySchema` with `direct` or `mysql` [strategies](../ddl-strategies), or plainly from their VTGate connection. | ||
|
||
## INSTANT DDL in managed schema changes | ||
|
||
With the `vitess` strategy, Vitess always prefers an Online DDL migration, which then allows [revertibility](../revertible-migrations). However, the `--prefer-instant-ddl` DDL strategy flag suggests to Vitess that, where possible, it should use `INSTANT` DDL. | ||
|
||
Vitess can predict whether a schema change is eligible to `INSTANT` DDL based on the existing table schema and the requested change. It is aware of the MySQL limitations (some of which are listed in the documentation) and can devise a plan for each distinct migration. If eligible for `INSTANT` DDL, and if `--prefer-instant-ddl` is specified, Vitess will automatically add `ALGORITHM=INSTANT` to the statement. Otherwise any `ALGORITHM` directive is ignored. | ||
|
||
If chosen to run as `INSTANT` DDL, the migration has no shadow table and is not revertible. | ||
|
||
## Example | ||
|
||
```sql | ||
|
||
mysql> set @@ddl_strategy='vitess --prefer-instant-ddl'; | ||
|
||
-- The migration is tracked, but the ALTER process won't start running. | ||
mysql> alter table corder add column name varchar(32); | ||
+--------------------------------------+ | ||
| uuid | | ||
+--------------------------------------+ | ||
| f0070c6e_abe1_11ef_a809_b27afeff3c85 | | ||
+--------------------------------------+ | ||
``` | ||
|
||
Migrations executed with `--prefer-instant-ddl` are visible on `show vitess_migrations` just like any other migration: | ||
|
||
|
||
```sql | ||
mysql> show vitess_migrations like 'f0070c6e_abe1_11ef_a809_b27afeff3c85' \G | ||
*************************** 1. row *************************** | ||
id: 1 | ||
migration_uuid: f0070c6e_abe1_11ef_a809_b27afeff3c85 | ||
keyspace: commerce | ||
shard: 0 | ||
mysql_schema: vt_commerce | ||
mysql_table: corder | ||
migration_statement: alter table corder add column `name` varchar(32) | ||
strategy: vitess | ||
options: --prefer-instant-ddl | ||
added_timestamp: 2024-11-26 12:33:55 | ||
requested_timestamp: 2024-11-26 12:33:55 | ||
ready_timestamp: NULL | ||
started_timestamp: 2024-11-26 12:33:57 | ||
liveness_timestamp: 2024-11-26 12:33:57 | ||
completed_timestamp: 2024-11-26 12:33:56.652159 | ||
cleanup_timestamp: NULL | ||
migration_status: complete | ||
log_path: | ||
artifacts: | ||
retries: 0 | ||
tablet: zone1-0000000101 | ||
tablet_failure: 0 | ||
progress: 100 | ||
migration_context: vtgate:e1131b44-abe1-11ef-a809-b27afeff3c85 | ||
ddl_action: alter | ||
message: | ||
... | ||
special_plan: {"operation":"instant-ddl"} | ||
``` | ||
|
||
Note the migration has no `artifacts`, and that it is executed with `special_plan: {"operation":"instant-ddl"}`. | ||
|
||
## PARTITIONING notes | ||
|
||
MySQL partitioning changes sometimes exhibit behaviors similar to `INSTANT` DDL, although partition management really operates on entire hidden tables. | ||
|
||
Vitess specifically addresses the common use case of [`RANGE` partitioned](https://dev.mysql.com/doc/refman/en/partitioning-management-range-list.html) tables and partition rotation. | ||
|
||
The operation `ALTER TABLE ... ADD PARTITION` creates a new empty hidden table, which implements the new partition. The operation is as fast as `CREATE TABLE`. It is wasteful to run this operation with Online DDL because the existing data is completely unaffected. Vitess always opts to run `ADD PARTITION` directly against MySQL, much like an `INSTANT` DDL, and the operation is not revertible. This behavior is not controlled by any flags. | ||
|
||
The operation `ALTER TABLE ... DROP PARTITION` drops one or more partitions, hence effectively drops one or more tables imlementing those partitions. It would be a logical error to run this operation with Online DDL, because the intended outcome is to drop rows of data, where an Online DDL operation would just copy those rows of data onto the next compatible partition. Vitess thus always opts to run `DROP PARTITION` directly against MySQL, and the operation is not revertible. This behavior is likewise not controlled by any flags. | ||
|
||
Vitess does not offer any special behavior for other types of partitioning schemes and operations. |
This file contains 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
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
content/en/docs/20.0/user-guides/schema-changes/concurrent-migrations.md
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
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.
I would remove the
/8.0/
part of the URLs so that we don't need to update them later. That will redirect to the latest GA LTS version page.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.
done