From 4a059be4803dac764a532919f48bf035a186bb4e Mon Sep 17 00:00:00 2001 From: Bine Date: Fri, 17 Oct 2025 22:17:10 +0200 Subject: [PATCH] Increase DB engine pool size and max overflow As described in #2568 when multiple clients connect simultaneously, an excessive number of database pool connections are created. This leads to resource exhaustion and connection management issues. We have introduced the pool_size and max_overflow parameters to better control the database connection pool. These parameters ensure the database can handle a sufficient number of concurrent connections without over-allocating resources. Added pool_size and max_overflow arguments to the database initialization. This change overrides the default initialization configuration where the temporary fix was applied. Co-Authored-By: Ufi <86113085+ufiking@users.noreply.github.com> --- gns3server/db/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gns3server/db/tasks.py b/gns3server/db/tasks.py index 6e147dcee..bfb7dac48 100644 --- a/gns3server/db/tasks.py +++ b/gns3server/db/tasks.py @@ -78,7 +78,7 @@ async def connect_to_db(app: FastAPI) -> None: db_path = os.path.join(Config.instance().config_dir, "gns3_controller.db") db_url = os.environ.get("GNS3_DATABASE_URI", f"sqlite+aiosqlite:///{db_path}") - engine = create_async_engine(db_url, connect_args={"check_same_thread": False, "timeout": 20}, future=True) + engine = create_async_engine(db_url, connect_args={"check_same_thread": False, "timeout": 20}, future=True, pool_size=512, max_overflow=1024) alembic_cfg = config.Config() alembic_cfg.set_main_option("script_location", "gns3server:db_migrations") #alembic_cfg.set_main_option('sqlalchemy.url', db_url)