fix: Fix parallel execution of alembic with PostgreSQL (#5408)
Fix parallel execution of alembic with PostgreSQL
This commit is contained in:
parent
b1536d3cb4
commit
9fc3601df8
3 changed files with 5 additions and 3 deletions
0
src/backend/base/langflow/alembic/__init__.py
Normal file
0
src/backend/base/langflow/alembic/__init__.py
Normal file
|
|
@ -1,9 +1,8 @@
|
||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
|
|
||||||
from alembic import context
|
from alembic import context
|
||||||
from sqlalchemy import engine_from_config, pool
|
from sqlalchemy import engine_from_config, pool, text
|
||||||
|
|
||||||
from langflow.services.database.models import *
|
|
||||||
from langflow.services.database.service import SQLModel
|
from langflow.services.database.service import SQLModel
|
||||||
|
|
||||||
# this is the Alembic Config object, which provides
|
# this is the Alembic Config object, which provides
|
||||||
|
|
@ -69,6 +68,9 @@ def run_migrations_online() -> None:
|
||||||
context.configure(connection=connection, target_metadata=target_metadata, render_as_batch=True)
|
context.configure(connection=connection, target_metadata=target_metadata, render_as_batch=True)
|
||||||
|
|
||||||
with context.begin_transaction():
|
with context.begin_transaction():
|
||||||
|
if connection.dialect.name == "postgresql":
|
||||||
|
connection.execute(text("SET LOCAL lock_timeout = '60s';"))
|
||||||
|
connection.execute(text("SELECT pg_advisory_xact_lock(112233);"))
|
||||||
context.run_migrations()
|
context.run_migrations()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ ignore_missing_imports = true
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
target-version = "py310"
|
target-version = "py310"
|
||||||
exclude = ["langflow/alembic"]
|
exclude = ["langflow/alembic/versions"]
|
||||||
line-length = 120
|
line-length = 120
|
||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue