sync update from LAN repo (source dhk-1 @ 3b1ec5b4)
This commit is contained in:
1 parent
da6521b6cb
commit
264e2200d6
995 files changed
+148105
-13399
No files matched your search
+28
@@ -0,0 +1,28 @@
|
||||
"""Helpers shared by the online Alembic environment and its tests."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
|
||||
def configure_mysql_migration_lock_waits(connection: Any) -> None:
|
||||
"""Set bounded MySQL DDL lock waits without leaving a transaction open.
|
||||
|
||||
SQLAlchemy starts an implicit transaction for ``SET SESSION`` on MySQL.
|
||||
Alembic's migration transaction then reuses it, and closing the connection
|
||||
rolls back the ``alembic_version`` updates even though MySQL DDL itself has
|
||||
already committed. Commit the session-local settings before Alembic starts
|
||||
its transaction so successful migrations are recorded durably.
|
||||
"""
|
||||
|
||||
try:
|
||||
lock_wait = int(os.getenv("DEER_FLOW_ALEMBIC_LOCK_WAIT", "15"))
|
||||
except ValueError:
|
||||
lock_wait = 15
|
||||
|
||||
connection.execute(text(f"SET SESSION lock_wait_timeout = {lock_wait}"))
|
||||
connection.execute(text(f"SET SESSION innodb_lock_wait_timeout = {lock_wait}"))
|
||||
connection.commit()
|
||||
Reference in new issue
Block a user