Query-wait-timeout (PGbouncer)
juventusjude
PROOP

a month ago

I currently have about 12 services connecting to my database. After running smoothly for a while, I began getting “too many client connection” errors, so I installed PgBouncer. It fixed the overload issue, but now I’m seeing a new error:

error: select * from information_schema.tables where table_name = $1 and table_schema = current_schema() - query_wait_timeout

From what I’ve learned, this happens when too many concurrent clients are waiting for connections and PgBouncer exceeds its query_wait_timeout limit.

I was advised to update my pgbouncer.ini with these settings:

pool_mode = transaction
query_timeout = 60
query_wait_timeout = 60
server_idle_timeout = 30

However, I’m not sure where to find the pgbouncer.ini file in my Railway project.

Since I plan to scale to over 100 services in the future, I’d like to know how to structure my setup to prevent this issue now and as the project grows.

Solved$15 Bounty

7 Replies

Railway
BOT

a month ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


passos
MODERATOR

a month ago

Hey, what PgBouncer template are you using?


juventusjude
PROOP

a month ago

PgBouncer

Lightweight connection pooler for PostgreSQL

142

100%

Brody's Projects


passos
MODERATOR

a month ago

Hey, sorry for the delay. That template simply uses the bitnami/pgbouncer image under the hood. You're able to configure it via environment variables too: https://github.com/bitnami/containers/blob/main/bitnami/pgbouncer/README.md

The important ones that I see are:

PGBOUNCER_QUERY_WAIT_TIMEOUT=60

PGBOUNCER_POOL_MODE=transaction

PGBOUNCER_SERVER_IDLE_TIMEOUT=30

PGBOUNCER_QUERY_TIMEOUT=60

Setting those environment variables on the PgBouncer service should do the trick.


juventusjude
PROOP

a month ago

Alright thanks for the info.
I am going to add to the pgbouncer environment?


juventusjude

Alright thanks for the info. I am going to add to the pgbouncer environment?

passos
MODERATOR

a month ago

Sure, let me know how it goes, and yeah you'll need to add to your PgBouncer service environment (hopefully that's a question and not a typo).


juventusjude
PROOP

a month ago

Yes. It worked. Thanks


Status changed to Solved samgordon about 1 month ago


Loading...