asyncpg.exceptions._base.InterfaceError: cannot call Connection.fetch(): connection has been released back to the pool
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 20/100
Research direction
Start with the Sanic and tortoise-orm request-handler versus background-task examples in the issue, then trace the pool.acquire and pool release paths shown in the screenshots. Reproduce the released PoolConnectionProxy error if possible and determine whether the background query uses a connection after release; done means the cause and a project-side fix or confirmed usage issue are documented.
Written by the indexing model from the issue text.
Description
- asyncpg version: 0.26.0
- PostgreSQL version: 12.0
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce : NO, from pg docker
the issue with a local PostgreSQL install?: YES, - Python version: Python 3.9.13
- Platform: MAC
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: From tortoise-orm
- If you built asyncpg locally, which version of Cython did you use?: No
- Can the issue be reproduced under both asyncio and
uvloop?: YES
I am using Sanic + tortoise-orm,
the test code as below:
when runs a query during the Request handler, it runs successfully
while runs in a background task, it report this error:
asyncpg.exceptions._base.InterfaceError: cannot call Connection.fetch(): connection has been released back to the pool
I found when the first time query, through the pool.acquire, got the right <PoolConnectionProxy <asyncpg.connection.Connection object at 0x7fd42102f9e0> 0x7fd3d018e550>
but when go to the background task query , the pool.acquire, got an "released" <PoolConnectionProxy [released] 0x7fd3d018e550>
I am confused how can I got an released PoolConnectionProxy from the same code
[query in the get Request method]

[query in the background task]

[the pool connection acquire method]

[the pool connection release method]

- 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 · 1 comment · 1 reaction ·
-
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 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
MagicStack/asyncpg#1330 · 1 comment ·
All issues in MagicStack/asyncpg
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
huggingface/Repo2RLEnv#163 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
NousResearch/hermes-agent#121143 ·