Does Vitess DDL revert guarantee data consistency after completion?
0 reputation · 05 Mar 2023, 10:42 UTC
0 reputation · 05 Mar 2023, 10:42 UTC
Vitess supports online schema migrations through declarative strategies that track state changes. While the system provides a REVERT command to apply inverse DDL, this process is a logical schema reversal rather than a point-in-time recovery.
The primary concern is whether the revert mechanism serves as a reliable rollback strategy once a migration has successfully cut over. Since a revert of an ADD COLUMN operation performs a DROP COLUMN, any data captured during the window between migration is permanently lost. Furthermore, the retention of artifact tables created during the table-swap phase is subject to garbage collection settings that limit manual recovery windows.
What are the constraints on retaining artifact tables to ensure a manual rollback if a revert is insufficient, and how does Vitess handle data consistency if a revert is triggered after concurrent writes have occurred on new schema elements?
31775 reputation · 05 Mar 2023, 11:48 UTC
No. A Vitess REVERT on a completed online DDL migration guarantees schema-level consistency — the table structure returns to its prior definition — but it makes no guarantee about data. Revert is a logical inverse DDL operation, not a point-in-time restore. If you revert an ADD COLUMN, Vitess issues a DROP COLUMN, and every row value written into that column since cutover is permanently destroyed.
Confirmed behavior of the online DDL lifecycle (Vitess 16+; verify against your version, as artifact-retention defaults have changed across releases):
If a revert runs after the application has written to new schema elements, those writes are simply dropped with the element. Vitess does not merge, archive, or warn. Consistency is preserved only in the narrow sense that the schema matches the pre-migration definition; the data does not. A revert immediately after cutover, before any writes land in new columns, is the only case where it approximates a true rollback.
Your real rollback safety net is the artifact table, not revert. To keep that option open:
vtctldclient GetTablet <alias> or inspect the --gc-lifecycle / artifact purge interval flags on vttablet. Defaults have shifted between versions, so confirm rather than assume.DROP on _vt_HOLD_.../_vt_EVAC_... artifact tables manually until the change is validated in production.On a staging keyspace: run an ADD COLUMN migration, insert rows with values in the new column, then REVERT and confirm the column and its data are gone. Separately, inspect information_schema.tables for _vt_% artifacts after cutover to learn your actual retention window. One missing detail that changes the recommendation: your Vitess version and vttablet GC flags — if you share those, the retention behavior can be pinned down precisely.
Treat revert as a schema convenience, not a recovery mechanism. For genuine rollback capability, control artifact-table retention and take a backup before cutover; assume anything written to new schema elements is forfeit the moment you revert.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.