Feature Request: Online DDL, in-order completion of migrations #12112
Labels
Component: Query Serving
Type: Enhancement
Logical improvement (somewhere between a bug and feature)
Type: Feature
Feature Description
ApplySchema
may run multiple schema changes. With Online DDL, and when--allow-concurrent
is given, those migrations may run concurrently. These migrations may then complete at any time of their choosing. ACREATE TABLE
migration, for example, can be expected to complete very quickly, as opposed to a long runningALTER TABLE
.Even when
--postpone-completion
is given, and even if we runALTER VITESS_MIGRATION COMPLETE ALL
when all migrations areready_to_complete
, even then the migrations may complete in any arbitrary order.We wish to introduce a new DDL strategy flag,
--in-order-completion
, which enforces the ordering of migration completion. A migration running with this strategy will only complete when it is the first non-pending migration in the same migration context group.That is, if there's any pending (
queued
,ready
,running
) migration whoseid
is smaller (thus, precedes our migration), our migration will stall and not complete.Note that it is possible for the migration to run if an earlier migration has
failed
. It's important to allow that to avoid hanging migrations.The outcome of this feature is that the order of migrations as submitted in
ApplySchema
is the order in which the migrations are finalized. The feature puts a specific order to what otherwise would be an arbitrary order.Tracking issue: #6926
Use Case(s)
The use case for this feature are migrations dependencies. Ideally, an
ApplySchema
should not have inter-dependencies between migrations, but it can happen.Examples:
VIEW
that selects from that column. In this situation, theALTER TABLE
must fully complete before we attempt to create the view, even though view creation is near instantaneous.With
--in-order-completion
, we assume the user has sorted out the correct order of migrations.vitess
does not attempt to order the migrations. The task is very complex and sometimes not at all possible. Possibly omething for the future, but not required for now.schemadiff
is able to resolve some ordering dependencies.The text was updated successfully, but these errors were encountered: