vtctl Rolling Upgrade vschema Consistency Gap
0 reputation · 28 May 2020, 10:06 UTC
0 reputation · 28 May 2020, 10:06 UTC
After a Vitess rolling upgrade initiated via vtctl in current releases, a failed step can leave vschema metadata in etcd out-of-sync with the actual tablet state across shards. This drift may not surface immediately but can cause DDL failures, query routing errors, or inconsistent results for downstream consumers. A Vitess vschema restoration command has a state requirement that all tablets must be in a healthy, consistent condition; if any tablet is still processing writes or holds partial changes, the command aborts or applies modifications incompletely. Compounding the issue, there is no automated pre-upgrade health-check that validates tablet readiness, forcing operators to manually verify row-level consistency before and after the upgrade sequence.
34775 reputation · 28 May 2020, 21:34 UTC
Vitess’s ResetSchema will only succeed when every tablet in the keyspace reports a Healthy status and has finished any pending schema changes. The command checks two conditions on each tablet:
Serving and Healthy in vtctld’s health table.vtctl GetTabletSchema should return the same schema as the live MySQL instance).If any tablet is in Pending, Unhealthy, or still applying a DDL, ResetSchema aborts to avoid partial routing updates. In practice, you should run:
vtctl GetTabletSchema --all
and confirm that every result matches the expected schema and that vtctld shows Healthy for all tablets before invoking ResetSchema.
etcd keeps a revision history for each key. You can restore a prior revision without restarting the topology by using etcdctl:
# View revision history (requires etcdctl v3.5+)
# Replace with your vschema key, e.g., /vitess/vschema/keyspace
etcdctl get /vitess/vschema/ --rev=0 --print-value-only | less
# Fetch a specific revision
etcdctl get /vitess/vschema/ --rev= --print-value-only > backup.json
# Restore that revision
etcdctl put /vitess/vschema/ @backup.json
After restoring, run vtctld --vschema_sync to push the corrected vschema to all tablets. Note that this bypasses Vitess validation, so the restored revision must match the live MySQL schemas to prevent routing errors.
vtctl GetTabletSchema --all and ensure all tablets report Healthy.vtctld --vschema_diff compares the etcd vschema against each tablet’s live schema. Review any mismatches.vtctld --vschema_sync to push the live schema back into etcd. If the live schema is correct, restore the appropriate etcd revision as described above.vtctl ResetSchema.These steps avoid data loss because they never drop or truncate tables; they only adjust routing metadata and ensure consistency between etcd and the MySQL instances.
Before proceeding, could you confirm whether any tablets still report a Pending DDL status after the upgrade attempt?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.