diff --git a/autogpt_platform/backend/backend/executor/scheduler.py b/autogpt_platform/backend/backend/executor/scheduler.py index 3c906a3af..edf126f69 100644 --- a/autogpt_platform/backend/backend/executor/scheduler.py +++ b/autogpt_platform/backend/backend/executor/scheduler.py @@ -99,6 +99,10 @@ class ExecutionScheduler(AppService): def get_port(cls) -> int: return config.execution_scheduler_port + @classmethod + def db_pool_size(cls) -> int: + return config.scheduler_db_pool_size + @property @thread_cached def execution_client(self) -> ExecutionManager: @@ -110,7 +114,11 @@ class ExecutionScheduler(AppService): self.scheduler = BlockingScheduler( jobstores={ "default": SQLAlchemyJobStore( - engine=create_engine(db_url), + engine=create_engine( + url=db_url, + pool_size=self.db_pool_size(), + max_overflow=0, + ), metadata=MetaData(schema=db_schema), ) } diff --git a/autogpt_platform/backend/backend/util/settings.py b/autogpt_platform/backend/backend/util/settings.py index 69504f528..409a18d93 100644 --- a/autogpt_platform/backend/backend/util/settings.py +++ b/autogpt_platform/backend/backend/util/settings.py @@ -153,6 +153,11 @@ class Config(UpdateTrackingModel["Config"], BaseSettings): description="The name of the Google Cloud Storage bucket for media files", ) + scheduler_db_pool_size: int = Field( + default=3, + description="The pool size for the scheduler database connection pool", + ) + @field_validator("platform_base_url", "frontend_base_url") @classmethod def validate_platform_base_url(cls, v: str, info: ValidationInfo) -> str: