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
This commit is contained in:
parent
ac54f82a80
commit
57a104ae37
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user