Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectionDoesNotExistError when releasing #624

Open
albertferras opened this issue Sep 23, 2020 · 0 comments
Open

ConnectionDoesNotExistError when releasing #624

albertferras opened this issue Sep 23, 2020 · 0 comments

Comments

@albertferras
Copy link

@albertferras albertferras commented Sep 23, 2020

  • asyncpg version: 0.21.0
  • PostgreSQL version: 10.7
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : no
  • Python version: 3.7
  • Platform: debian (docker image python:3.7.9-slim)
  • Do you use pgbouncer?: no
  • Did you install asyncpg with pip?: yes
  • If you built asyncpg locally, which version of Cython did you use?: no
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : only tried asyncio

I've found the following exception in our logs:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 214, in release
    self._con.terminate()
AttributeError: 'NoneType' object has no attribute 'terminate'

During handling of the above exception, another exception occurred:
File "/usr/local/lib/python3.7/site-packages/my_code_calling_release.py", line 40, in acquire
     await self.pool.release(con)
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 654, in release
     return await asyncio.shield(ch.release(timeout))   
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 216, in release
     raise ex   
File "/usr/local/lib/python3.7/site-packages/asyncpg/pool.py", line 206, in release
     await self._con.reset(timeout=budget)
File "/usr/local/lib/python3.7/site-packages/asyncpg/connection.py", line 1137, in reset
     await self.execute(reset_query, timeout=timeout)
File "/usr/local/lib/python3.7/site-packages/asyncpg/connection.py", line 295, in execute
     return await self._protocol.query(query, timeout)
File "asyncpg/protocol/protocol.pyx", line 316, in query

From what I can see, the call at self._con.reset is raising a ConnectionDoesNotExistError.
Should the exception be reraised at line 218 if the exception is an ConnectionDoesNotExistError (we know it's already closed)? It shouldn't even try to self._con.terminate() because self._con is already None (see the exception).

Not sure if the comments in that code still apply for that type of exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.