1
I had a nasty MySQL problem arise the other day. I added two new columns to table 'Promotions' (13 existing columns, ~750 records) using the PHPMyAdmin interface. This query ("ALTER TABLE.....") never fully executed and locked the table, so that each subsequent query to 'Promotions' would hang and queue up. It took me about an hour to realize this was happening, and the problem was resolved by me rebooting my database.
Are there standard precautions that need to be taken and known issues that arise from altering database schemas? I have never seen this kind of locking happen before.
How would you stop the tables become desync'd between steps 3 and 5? – eggyal – 2012-11-09T00:39:59.497
There is not a perfect solution for situations like this. Altering a live table requires a little downtime but if huge concurrency and business-critical data are not in stage, this method will be useful. Also facebook engineers spent lot of time to solve this problem too : https://www.facebook.com/notes/mysql-at-facebook/online-schema-change-for-mysql/430801045932
– None – 2012-11-09T00:58:41.647Yes, this definitely makes sense. In this case there wasn't "a little downtime" though, it was completely locked out for at least one hour. I wish I had had some tools in place to run analysis on what exactly was happening before I rebooted the instance. – None – 2012-11-09T02:04:52.227