sync update from LAN repo (source master @ ca48c4ec)
This commit is contained in:
1 parent
8bc8b0e082
commit
ea9dcff9c0
873 files changed
+107866
-14011
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