A financial platform hosts stateless microservices on Cloud Run connected to a Cloud SQL for PostgreSQL instance. The application team plans to release a major update that requires a breaking database schema change, specifically renaming a critical column and changing its data type. The team must execute a zero-downtime canary deployment using Cloud Run traffic splitting, while maintaining the ability to instantly roll back traffic to the previous application revision without causing runtime errors or data corruption for users on either revision. Which release management strategy should you implement?
- Implement an expand-contract database migration pattern by adding the new column alongside the existing column, deploying the new Cloud Run revision using gradual traffic splitting, and removing the legacy column only after the new revision is fully deployed and verified.Answer
- BApply the DDL migration script to rename the column directly in Cloud SQL immediately before initiating the Cloud Run canary traffic split to ensure the database schema matches the incoming revision.
- CConfigure the Cloud Run service startup probe to run a database DDL validation query that checks for the newly renamed column, ensuring traffic is routed only after the database migration finishes.
- DGrant the CI/CD pipeline service account the Project Editor role (`roles/editor`) so it can perform schema DDL operations and execute Cloud Run traffic splitting within a single pipeline execution step.
Answer
Implement an expand-contract database migration pattern by adding the new column alongside the existing column, deploying the new Cloud Run revision using gradual traffic splitting, and removing the legacy column only after the new revision is fully deployed and verified.
The correct strategy uses an expand-contract (also known as parallel run) database migration pattern. In canary deployments or blue-green releases, multiple application revisions run concurrently against the same database backend. To prevent runtime errors and ensure instant rollback capability, database schema changes must be non-breaking and backward-compatible. Adding the new column while writing to both columns ensures that the old application version continues working seamlessly alongside the canary version.
Step-by-Step Solution
Key Concept
Decoupling Database Schema Migrations from Application Deployments (Expand-Contract Pattern)
Estimated Time:3m 0s