dipdup-io / dipdup

Modular framework for creating selective indexers and featureful backends for dapps
https://dipdup.io
MIT License
92 stars 52 forks source link

Prepared statement "__asyncpg_stmt_e__" does not exist #921

Closed pyk closed 8 months ago

pyk commented 8 months ago

Steps to reproduce:

  1. Setup postgres with pgbouncer
  2. run dipdup with the following config
database:
  kind: postgres
  host: ${POSTGRES_HOST}
  port: ${POSTGRES_PORT}
  user: ${POSTGRES_USER}
  password: ${POSTGRES_PASSWORD}
  database: ${POSTGRES_DB}
  schema_name: ${POSTGRES_SCHEMA}

use pgbouncer

What did you expect to happen: Can run dipdup normally

What actually happened: I got the following error:

  File "asyncpg/protocol/protocol.pyx", line 207, in bind_execute
asyncpg.exceptions.InvalidSQLStatementNameError: prepared statement "__asyncpg_stmt_e__" does not exist
HINT:  
NOTE: pgbouncer with pool_mode set to "transaction" or
"statement" does not support prepared statements properly.
You have two options:

* if you are using pgbouncer for connection pooling to a
  single server, switch to the connection pool functionality
  provided by asyncpg, it is a much better option for this
  purpose;

* if you have no option of avoiding the use of pgbouncer,
  then you can set statement_cache_size to 0 when creating
  the asyncpg connection object.

Environment

pyk commented 8 months ago

Oops, my bad. Turns out I had to switch on session mode in pgbouncer. It's all running smoothly now