How do you deal with long-running database migrations in CD?
AdvancedProductionRelease Engineering and Progressive Delivery
Answer
Decouple them from the release: run them as a separate pipeline job ahead of deploys, make them online and batched (backfills in chunks with throttling, tracking progress), avoid long locks (ALTER TABLE on big tables can block writes; use online schema change tools), monitor replication lag, and make them resumable and idempotent. Application code must work before, during and after the migration, controlled by flags. Set statement and lock timeouts so a migration fails fast rather than taking the database down.
SET lock_timeout = '3s';
CREATE INDEX CONCURRENTLY idx_orders_customer ON orders (customer_id);
More on Release Engineering and Progressive Delivery
How do you do zero-downtime deployments on Kubernetes?IntermediateHow do you implement a canary release with Argo Rollouts and automated analysis?AdvancedHow do you roll back safely when a deploy includes a database migration?AdvancedHow do you design an automated rollback trigger?AdvancedHow do you handle hotfixes in a trunk-based flow?IntermediateHow do you version and release libraries versus services?Intermediate