Open
Description
- asyncpg version: 0.27.0
- PostgreSQL version: 14.7
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: We can reproduce it, not locally - Python version: 3.10.2
- Platform: Backend: Linux, t3large AWS instance, Database: AWS RDS
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
We're using FastAPI ,and our current code for setting up the db connection is:
connection_arguments: Dict[str, Any] = {"server_settings": {"jit": "off"}}
ENUM_TYPES = (
("public", "sometype"), ...
)
async def register_enum_types(conn) -> None:
for enum_class, typename in ENUM_TYPES:
await conn.set_builtin_type_codec(
typename, schema=enum_class, codec_name="text"
)
engine = create_async_engine(
settings.uri,
echo=False,
connect_args=connection_arguments,
pool_size=200,
max_overflow=10,
)
async_sessionmaker = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
@event.listens_for(engine.sync_engine, "connect")
def on_connect(dbapi_connection, connection_record):
dbapi_connection.run_async(register_enum_types)
We added the register_enum_types
as we were thinking that the query:
SELECT t.oid, t.typelem AS elemtype, t.typtype AS kind FROM pg_catalog.pg_type AS t WHERE t.oid = $1
which we saw a lot in AWS RDS monitoring is causing the issue, but now we're not sure what is it anymore.
In logs when it happens we see:
File "/path/to/file/python3.10/site-packages/asyncpg/connect_utils.py", line 780, in _connect_addr raise asyncio.TimeoutError asyncio.exceptions.TimeoutError
and after some time, it gets back to normal.
Metadata
Metadata
Assignees
Labels
No labels