feat: Add small pool for PostgreSQL connections to allow multiple docker instances communicating with PostgreSQL
This commit is contained in:
parent
ba33dca592
commit
b1e47d9e0d
1 changed files with 5 additions and 2 deletions
|
|
@ -12,7 +12,6 @@ from sqlalchemy import NullPool, text, select, MetaData, Table, delete, inspect
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine, async_sessionmaker
|
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine, async_sessionmaker
|
||||||
|
|
||||||
from cognee.modules.data.models.Data import Data
|
from cognee.modules.data.models.Data import Data
|
||||||
from cognee.modules.sync.models.SyncOperation import SyncOperation
|
|
||||||
from cognee.shared.logging_utils import get_logger
|
from cognee.shared.logging_utils import get_logger
|
||||||
from cognee.infrastructure.utils.run_sync import run_sync
|
from cognee.infrastructure.utils.run_sync import run_sync
|
||||||
from cognee.infrastructure.databases.exceptions import EntityNotFoundError
|
from cognee.infrastructure.databases.exceptions import EntityNotFoundError
|
||||||
|
|
@ -58,7 +57,11 @@ class SQLAlchemyAdapter:
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.engine = create_async_engine(
|
self.engine = create_async_engine(
|
||||||
connection_string, pool_size=12, max_overflow=12, poolclass=None
|
connection_string,
|
||||||
|
pool_size=1, # one physical session per container
|
||||||
|
max_overflow=1,
|
||||||
|
pool_recycle=280, # keep below RDS 300 s idle kill
|
||||||
|
pool_pre_ping=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.sessionmaker = async_sessionmaker(bind=self.engine, expire_on_commit=False)
|
self.sessionmaker = async_sessionmaker(bind=self.engine, expire_on_commit=False)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue