fix: Fix parallel execution of alembic with PostgreSQL (#5408)

Fix parallel execution of alembic with PostgreSQL
This commit is contained in:
Christophe Bornet 2024-12-23 19:53:07 +01:00 committed by GitHub
commit 9fc3601df8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View file

@ -1,9 +1,8 @@
from logging.config import fileConfig
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
# 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)
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()

View file

@ -24,7 +24,7 @@ ignore_missing_imports = true
[tool.ruff]
target-version = "py310"
exclude = ["langflow/alembic"]
exclude = ["langflow/alembic/versions"]
line-length = 120
[tool.ruff.lint]