TimeoutError on multiple requests
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 28/100
Research direction
Start at asyncpg/connect_utils.py:780, where the reported asyncio.TimeoutError is raised, and review the connection setup using FastAPI, SQLAlchemy pooling, and AWS RDS. Compare the timeout logs with the concurrent pool settings and the reported pg_catalog query. Done means establishing a reproducible cause and a verified fix or clear diagnosis.
Written by the indexing model from the issue text.
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.
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 469
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 9
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MagicStack/asyncpg
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
MagicStack/asyncpg#1357 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
MagicStack/asyncpg#1354 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
MagicStack/asyncpg#1342 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 56/100
MagicStack/asyncpg#1340 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 28/100
MagicStack/asyncpg#1337 ·
All issues in MagicStack/asyncpg
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
canonical/paas-charm#368 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
StevenBlack/hosts#3256 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
qualcomm/qai-appbuilder#275 ·