Skip to content

Pgbouncer and 'prepared statement does not exist'#198

@AmatanHead

Description

@AmatanHead
  • asyncpg version: 0.12.0
  • PostgreSQL version: 9.6
  • Python version: 3.6.2
  • Platform: ubuntu 16.04
  • Do you use pgbouncer?: yes
  • Did you install asyncpg with pip?: yes
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : don't know

Hello! I'm trying to use asyncpg with pgbouncer. I've set statement_cache_size=0 but I still get errors. What am I doing wrong?

In [1]: importos, asyncpg, asyncioIn [2]: loop=asyncio.get_event_loop() In [3]: conn=loop.run_until_complete(asyncpg.connect( ...: host='pgaas.mail.yandex.net', ...: port=12000, ...: user='statinfra_api', ...: database='statinfra_api_beta', ...: password=os.environ['DB_PASSWORD'], ...: ssl=True, ...: statement_cache_size=0 ...: )) In [4]: loop.run_until_complete(conn.fetch('SELECT * FROM tasks')) ---------------------------------------------------------------------------InvalidSQLStatementNameErrorTraceback (mostrecentcalllast) <ipython-input-5-8a44237acb87>in<module>() ---->1loop.run_until_complete(conn.fetch('SELECT * FROM tasks')) /usr/lib/python3.6/asyncio/base_events.pyinrun_until_complete(self, future) 465raiseRuntimeError('Event loop stopped before Future completed.') 466-->467returnfuture.result() 468469defstop(self): ~/.virtualenvs/statbox-abt-backend/lib/python3.6/site-packages/asyncpg/connection.pyinfetch(self, query, timeout, *args) 339""" 340 self._check_open()--> 341 return await self._execute(query, args, 0, timeout) 342  343 async def fetchval(self, query, *args, column=0, timeout=None):~/.virtualenvs/statbox-abt-backend/lib/python3.6/site-packages/asyncpg/connection.py in _execute(self, query, args, limit, timeout, return_status) 1186 timeout = self._protocol._get_timeout(timeout) 1187 with self._stmt_exclusive_section:-> 1188 return await self._do_execute(query, executor, timeout) 1189  1190 async def _executemany(self, query, args, timeout):~/.virtualenvs/statbox-abt-backend/lib/python3.6/site-packages/asyncpg/connection.py in _do_execute(self, query, executor, timeout, retry) 1197 async def _do_execute(self, query, executor, timeout, retry=True): 1198 if timeout is None:-> 1199 stmt = await self._get_statement(query, None) 1200 else: 1201 before = time.monotonic()~/.virtualenvs/statbox-abt-backend/lib/python3.6/site-packages/asyncpg/connection.py in _get_statement(self, query, timeout, named) 290 self._types_stmt = await self.prepare(self._intro_query) 291 --> 292 types = await self._types_stmt.fetch(list(ready)) 293 self._protocol.get_settings().register_data_types(types) 294 ~/.virtualenvs/statbox-abt-backend/lib/python3.6/site-packages/asyncpg/prepared_stmt.py in fetch(self, timeout, *args) 155 :return: A list of :class:`Record` instances. 156 """-->157data=awaitself.__bind_execute(args, 0, timeout) 158returndata159~/.virtualenvs/statbox-abt-backend/lib/python3.6/site-packages/asyncpg/prepared_stmt.pyin__bind_execute(self, args, limit, timeout) 194protocol=self._connection._protocol195data, status, _=awaitprotocol.bind_execute( -->196self._state, args, '', limit, True, timeout) 197self._last_status=status198returndata~/.virtualenvs/statbox-abt-backend/lib/python3.6/site-packages/asyncpg/protocol/protocol.pyxinbind_execute (asyncpg/protocol/protocol.c:66799)() InvalidSQLStatementNameError: preparedstatement"__asyncpg_stmt_1__"doesnotexist

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions