mirror of
https://github.com/langgenius/dify.git
synced 2026-04-05 19:59:21 +08:00
feat: make SQLALCHEMY_POOL_TIMEOUT configurable (#25468)
Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -76,6 +76,7 @@ DB_HOST=localhost
|
|||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
DB_DATABASE=dify
|
DB_DATABASE=dify
|
||||||
SQLALCHEMY_POOL_PRE_PING=true
|
SQLALCHEMY_POOL_PRE_PING=true
|
||||||
|
SQLALCHEMY_POOL_TIMEOUT=30
|
||||||
|
|
||||||
# Storage configuration
|
# Storage configuration
|
||||||
# use for store upload files, private keys...
|
# use for store upload files, private keys...
|
||||||
|
|||||||
@@ -187,6 +187,11 @@ class DatabaseConfig(BaseSettings):
|
|||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SQLALCHEMY_POOL_TIMEOUT: NonNegativeInt = Field(
|
||||||
|
description="Number of seconds to wait for a connection from the pool before raising a timeout error.",
|
||||||
|
default=30,
|
||||||
|
)
|
||||||
|
|
||||||
RETRIEVAL_SERVICE_EXECUTORS: NonNegativeInt = Field(
|
RETRIEVAL_SERVICE_EXECUTORS: NonNegativeInt = Field(
|
||||||
description="Number of processes for the retrieval service, default to CPU cores.",
|
description="Number of processes for the retrieval service, default to CPU cores.",
|
||||||
default=os.cpu_count() or 1,
|
default=os.cpu_count() or 1,
|
||||||
@@ -216,6 +221,7 @@ class DatabaseConfig(BaseSettings):
|
|||||||
"connect_args": connect_args,
|
"connect_args": connect_args,
|
||||||
"pool_use_lifo": self.SQLALCHEMY_POOL_USE_LIFO,
|
"pool_use_lifo": self.SQLALCHEMY_POOL_USE_LIFO,
|
||||||
"pool_reset_on_return": None,
|
"pool_reset_on_return": None,
|
||||||
|
"pool_timeout": self.SQLALCHEMY_POOL_TIMEOUT,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ def test_flask_configs(monkeypatch: pytest.MonkeyPatch):
|
|||||||
"pool_size": 30,
|
"pool_size": 30,
|
||||||
"pool_use_lifo": False,
|
"pool_use_lifo": False,
|
||||||
"pool_reset_on_return": None,
|
"pool_reset_on_return": None,
|
||||||
|
"pool_timeout": 30,
|
||||||
}
|
}
|
||||||
|
|
||||||
assert config["CONSOLE_WEB_URL"] == "https://example.com"
|
assert config["CONSOLE_WEB_URL"] == "https://example.com"
|
||||||
|
|||||||
@@ -225,6 +225,9 @@ SQLALCHEMY_ECHO=false
|
|||||||
SQLALCHEMY_POOL_PRE_PING=false
|
SQLALCHEMY_POOL_PRE_PING=false
|
||||||
# Whether to enable the Last in first out option or use default FIFO queue if is false
|
# Whether to enable the Last in first out option or use default FIFO queue if is false
|
||||||
SQLALCHEMY_POOL_USE_LIFO=false
|
SQLALCHEMY_POOL_USE_LIFO=false
|
||||||
|
# Number of seconds to wait for a connection from the pool before raising a timeout error.
|
||||||
|
# Default is 30
|
||||||
|
SQLALCHEMY_POOL_TIMEOUT=30
|
||||||
|
|
||||||
# Maximum number of connections to the database
|
# Maximum number of connections to the database
|
||||||
# Default is 100
|
# Default is 100
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ x-shared-env: &shared-api-worker-env
|
|||||||
SQLALCHEMY_ECHO: ${SQLALCHEMY_ECHO:-false}
|
SQLALCHEMY_ECHO: ${SQLALCHEMY_ECHO:-false}
|
||||||
SQLALCHEMY_POOL_PRE_PING: ${SQLALCHEMY_POOL_PRE_PING:-false}
|
SQLALCHEMY_POOL_PRE_PING: ${SQLALCHEMY_POOL_PRE_PING:-false}
|
||||||
SQLALCHEMY_POOL_USE_LIFO: ${SQLALCHEMY_POOL_USE_LIFO:-false}
|
SQLALCHEMY_POOL_USE_LIFO: ${SQLALCHEMY_POOL_USE_LIFO:-false}
|
||||||
|
SQLALCHEMY_POOL_TIMEOUT: ${SQLALCHEMY_POOL_TIMEOUT:-30}
|
||||||
POSTGRES_MAX_CONNECTIONS: ${POSTGRES_MAX_CONNECTIONS:-100}
|
POSTGRES_MAX_CONNECTIONS: ${POSTGRES_MAX_CONNECTIONS:-100}
|
||||||
POSTGRES_SHARED_BUFFERS: ${POSTGRES_SHARED_BUFFERS:-128MB}
|
POSTGRES_SHARED_BUFFERS: ${POSTGRES_SHARED_BUFFERS:-128MB}
|
||||||
POSTGRES_WORK_MEM: ${POSTGRES_WORK_MEM:-4MB}
|
POSTGRES_WORK_MEM: ${POSTGRES_WORK_MEM:-4MB}
|
||||||
|
|||||||
Reference in New Issue
Block a user