From 4864129a6ea5819bad723a34291744d56428e113 Mon Sep 17 00:00:00 2001 From: Eduardo Lauer Date: Thu, 16 Oct 2025 16:12:10 -0300 Subject: [PATCH 1/2] increase pool_size --- src/db_config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/db_config.py b/src/db_config.py index 75ee739..7621b5a 100644 --- a/src/db_config.py +++ b/src/db_config.py @@ -14,9 +14,9 @@ engine = create_async_engine( SQLALCHEMY_DATABASE_URL, - pool_size=15, - max_overflow=15, - pool_timeout=30, + pool_size=30, + max_overflow=20, + pool_timeout=60, ) sync_engine = create_engine(SQLALCHEMY_DATABASE_URL) From e3ec97e42ae7a38300e7881b5d93113918cc8106 Mon Sep 17 00:00:00 2001 From: Eduardo Lauer Date: Thu, 16 Oct 2025 16:12:51 -0300 Subject: [PATCH 2/2] check if is not a transaction before commit/rollback --- src/db_config.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/db_config.py b/src/db_config.py index 7621b5a..8586444 100644 --- a/src/db_config.py +++ b/src/db_config.py @@ -96,12 +96,9 @@ async def __aenter__(self): async def __aexit__(self, exc_type, exc_value, traceback): try: - if exc_type is None: - # 2. If NO exception occurred, commit the transaction. + if not self.db.in_transaction() and exc_type is None: await self.db.commit() - else: - # 3. If an exception DID occur, roll back the transaction. + elif not self.db.in_transaction(): await self.db.rollback() finally: - # 4. ALWAYS close the session. await self.db.close()