Description
- asyncpg version: 0.9.0, 0.10.1
- PostgreSQL version: 9.6
- Python version: 3.6
- Platform: FreeBSD 10.2
- Do you use pgbouncer?:
noyes - Did you install asyncpg with pip?: yes
- If you built asyncpg locally, which version of Cython did you use?: yes
- Can the issue be reproduced under both asyncio and
uvloop?: yes
Hi!
We notice a problem that issue name describes pretty well. How did we get it?
We have a small aiohttp service which runs a static query to PostgreSQL database on every handled request. Like SELECT foo, bar FROM table ORDER BY baz
. No parameters, nothing all. That's the only query we executre to database. We're using connection pool sized from 1 to 4 connections as well, the rest parameters are default (except connection one of course).
Everything works fine until eventually we starting get the InvalidSQLStatementNameError exception on connection.fetch
call. It doesn't happens instantly, it occurs after few hours of service uptime. Sometimes every .fetch
call ends with that exception. Sometimes every even only. The number of __asyncpg_stmt_
token is always different, but stable until restart when error occurs.
We tried to disable statements cache at all, set it to zero. This didn't happened. We thought that 0.10 release will fix that problem. Suddenly, it doesn't. We played around the cache size, connection pool size, connection life time, but all ended with the same issue. Difference may be in dozen of minutes, but all ends similar.
It's quite hard for me to provide any example to reproduce the problem because everything just works for a quite long time. Except that particular service, which isn't quite different, doesn't uses any hacks, globals, pretty trivial. Just no idea what to try next.
The last bits of the traceback are here:
File "/usr/local/lib/python3.6/site-packages/asyncpg/connection.py", line 340, in fetch
return await self._execute(query, args, 0, timeout)
File "/usr/local/lib/python3.6/site-packages/asyncpg/connection.py", line 651, in _execute
return await self._do_execute(query, executor, timeout)
File "/usr/local/lib/python3.6/site-packages/asyncpg/connection.py", line 672, in _do_execute
result = await executor(stmt, None)
File "asyncpg/protocol/protocol.pyx", line 170, in bind_execute (asyncpg/protocol/protocol.c:57679)
asyncpg.exceptions.InvalidSQLStatementNameError: prepared statement "__asyncpg_stmt_37__" does not exist
Any ideas how to debug this issue? Or workaround it? Would be grateful for any help.