Close DB migration sessions explicitly for compatibility with PyMySQL
oslo.db lib starting with version 1.12.0 uses PyMySQL as mysql client. We get problem with it as it does not close opened sessions by default. And if we do some actions with migration sessions and do not close sessions, then alembic, as db migration tool does not write to DB updated migration version, that is final step of each migration. It breaks further attempts to perform some migration actions in case some migration can not be applied twice. Because of improper versions in DB, alembic tries to execute same migrations again and again. So, close migration sessions explicitly since PyMySQL does not do it itself. Also, print version in devstack for getting more details in future debug of devstack installation output. Change-Id: I5c729f10bac23b1853e18127b50b1d9f053ab629 Closes-Bug: #1473400
This commit is contained in:
parent
1083688bba
commit
503203e243
|
@ -467,6 +467,9 @@ function init_manila {
|
|||
# (re)create manila database
|
||||
recreate_database manila utf8
|
||||
$MANILA_BIN_DIR/manila-manage db sync
|
||||
|
||||
# Display version as debug-action (see bug/1473400)
|
||||
$MANILA_BIN_DIR/manila-manage db version
|
||||
fi
|
||||
|
||||
# Create cache dir
|
||||
|
|
|
@ -55,7 +55,8 @@ def upgrade():
|
|||
sa.Column('updated_at', sa.DateTime))
|
||||
|
||||
export_locations = []
|
||||
for share in op.get_bind().execute(shares_table.select()):
|
||||
session = sa.orm.Session(bind=op.get_bind().connect())
|
||||
for share in session.query(shares_table).all():
|
||||
deleted = share.deleted if isinstance(share.deleted, int) else 0
|
||||
export_locations.append({
|
||||
'created_at': share.created_at,
|
||||
|
@ -68,6 +69,7 @@ def upgrade():
|
|||
op.bulk_insert(export_locations_table, export_locations)
|
||||
|
||||
op.drop_column('shares', 'export_location')
|
||||
session.close_all()
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
@ -106,3 +108,4 @@ def downgrade():
|
|||
connection.execute(update)
|
||||
|
||||
op.drop_table('share_export_locations')
|
||||
session.close_all()
|
||||
|
|
|
@ -70,6 +70,7 @@ def upgrade():
|
|||
})
|
||||
|
||||
op.bulk_insert(es_table, extra_specs)
|
||||
session.close_all()
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
|
Loading…
Reference in New Issue