From 57a104ae3759a907f2adededbdf6f890cb23d4fc Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Fri, 27 Nov 2015 06:10:40 -0800 Subject: [PATCH] Set old_alter_table during large mysql migration MySQL uses too much tmpdir space to do its newer ALTER optimizations, so we revert to the simpler method which creates a new table and locks the old one during the entire operation. Change-Id: Ifad26f9e7ee70a8acf0f08d6296b97daf500f30b --- .../versions/2822a408bdd0_uuid_to_integer_ids.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/subunit2sql/migrations/versions/2822a408bdd0_uuid_to_integer_ids.py b/subunit2sql/migrations/versions/2822a408bdd0_uuid_to_integer_ids.py index e8fe420..1a85b07 100644 --- a/subunit2sql/migrations/versions/2822a408bdd0_uuid_to_integer_ids.py +++ b/subunit2sql/migrations/versions/2822a408bdd0_uuid_to_integer_ids.py @@ -214,6 +214,15 @@ def upgrade(): op.alter_column('runs_new', 'new_id', new_column_name='id') else: + # http://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-syntax.html + # Ths is a specific workaround for limited tmpdir space in the + # OpenStack infra MySQL server. With old_alter_table=OFF, mysql creates + # temporary files that are very large while building the new table. + # So generally, while the old method is less desirable for concurrency, + # it is safer, and we don't need online DDL since this migration + # uses a _new table anyway. + if migration_context.dialect.name == 'mysql': + op.execute('SET SESSION old_alter_table=ON') with op.batch_alter_table("attachments_new") as batch_op: batch_op.drop_column('id') batch_op.alter_column('new_id', new_column_name='id',