Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
chore: add SQLALCHEMY_POOL_USE_LIFO option and missing SQLALCHEMY_POOL_PRE_PING env default value. (#22371)
Jacky Wuda53bf511f49
diff --git a/api/configs/middleware/__init__.py b/api/configs/middleware/__init__.pyindex 427602676fe..0c0c06dd464 100644--- a/api/configs/middleware/__init__.py+++ b/api/configs/middleware/__init__.py@@ -162,6 +162,11 @@ class DatabaseConfig(BaseSettings):default=3600,)+ SQLALCHEMY_POOL_USE_LIFO: bool = Field(+ description="If True, SQLAlchemy will use last-in-first-out way to retrieve connections from pool.",+ default=False,+ )+SQLALCHEMY_POOL_PRE_PING: bool = Field(description="If True, enables connection pool pre-ping feature to check connections.",default=False,@@ -199,6 +204,7 @@ class DatabaseConfig(BaseSettings):"pool_recycle": self.SQLALCHEMY_POOL_RECYCLE,"pool_pre_ping": self.SQLALCHEMY_POOL_PRE_PING,"connect_args": connect_args,+ "pool_use_lifo": self.SQLALCHEMY_POOL_USE_LIFO,}diff --git a/api/tests/unit_tests/configs/test_dify_config.py b/api/tests/unit_tests/configs/test_dify_config.pyindex b70c8830ede..e9d4ee19358 100644--- a/api/tests/unit_tests/configs/test_dify_config.py+++ b/api/tests/unit_tests/configs/test_dify_config.py@@ -88,6 +88,7 @@ def test_flask_configs(monkeypatch):"pool_pre_ping": False,"pool_recycle": 3600,"pool_size": 30,+ "pool_use_lifo": False,}assert config["CONSOLE_WEB_URL"] == "https://example.com"diff --git a/docker/.env.example b/docker/.env.exampleindex dabd66f2850..e08a81e49e9 100644--- a/docker/.env.example+++ b/docker/.env.example@@ -214,6 +214,10 @@ SQLALCHEMY_POOL_SIZE=30SQLALCHEMY_POOL_RECYCLE=3600# Whether to print SQL, default is false.SQLALCHEMY_ECHO=false+# If True, will test connections for liveness upon each checkout+SQLALCHEMY_POOL_PRE_PING=false+# Whether to enable the Last in first out option or use default FIFO queue if is false+SQLALCHEMY_POOL_USE_LIFO=false# Maximum number of connections to the database# Default is 100diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yamlindex 61362ed9fda..73e061e7700 100644--- a/docker/docker-compose.yaml+++ b/docker/docker-compose.yaml@@ -56,6 +56,8 @@ x-shared-env: &shared-api-worker-envSQLALCHEMY_POOL_SIZE: ${SQLALCHEMY_POOL_SIZE:-30}SQLALCHEMY_POOL_RECYCLE: ${SQLALCHEMY_POOL_RECYCLE:-3600}SQLALCHEMY_ECHO: ${SQLALCHEMY_ECHO:-false}+ SQLALCHEMY_POOL_PRE_PING: ${SQLALCHEMY_POOL_PRE_PING:-false}+ SQLALCHEMY_POOL_USE_LIFO: ${SQLALCHEMY_POOL_USE_LIFO:-false}POSTGRES_MAX_CONNECTIONS: ${POSTGRES_MAX_CONNECTIONS:-100}POSTGRES_SHARED_BUFFERS: ${POSTGRES_SHARED_BUFFERS:-128MB}POSTGRES_WORK_MEM: ${POSTGRES_WORK_MEM:-4MB}