The problem wasn’t the logic. It was the new column.
In most systems, adding a new column to a database table seems straightforward. You write an ALTER TABLE statement, run it, and move on. In practice, it can trigger long locks, block writes, spike CPU usage, or cause deploy rollbacks. At scale, a poorly planned new column can take down an entire service for minutes—or hours.
A new column changes storage layout. On large tables, this can involve rewriting every row on disk. In production, that rewrite can clash with live traffic. Without zero-downtime strategies, the database may queue all writes until the operation ends. High-load APIs will stall. Background jobs will fail. Users will notice.
Safe deployments of new columns require more than SQL syntax. Use online schema change tools (like pt-online-schema-change or gh-ost) to stage the update in small chunks. Test on a replica before touching production. Monitor performance metrics in real time, including I/O wait, replication lag, and transaction throughput.