45 minutes ago · Tech · hide

Recently, I worked on a database migration at work where I had to plan a database migration rollout across releases to avoid downtime. For this, I applied the expand and contract pattern, even though, at the time, I didn’t know there was a name for it. I now realize, though, that the contract phase should’ve gone out in two phases. This post is more of a “today I learned” sort of thing. Many of you will probably know what expand and contract is. If I had to describe it in a single line, I’d say: you first add the new things, then migrate, then remove the old things, in different deploys. Simple as that. What happened is that we experienced a few seconds of downtime during the contract phase. We had agreed that this could happen. After all, DROPping a COLUMN requires exclusive access to the table, blocking any other operations on that table. What I hadn’t really thought about was the way Postgres gets the lock. Before it can take it, the migration has to first wait for every query…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town