pgwatch2 icon indicating copy to clipboard operation
pgwatch2 copied to clipboard

pgwatch2 using pgbouncer problem

Open yinan8128 opened this issue 2 years ago • 3 comments

Hi pgwatch2 team,

As described in #348, once we switch pgwatch2 to pgbouncer transaction mode, as pgbouncer transaction mode doesn't support "prepared statement" then caused "pq: unnamed prepared statement" error.

So we switched pgwatch2 to pgbouncer session mode but faced pgbouncer_pools_client_maxwait_seconds too high problem(please check attached image file), this happened in postgresql replication node and there was very low load in the period, so mostly like caused by pgwatch2 using pgbouncer session mode.

image

Go uses prepared statements by default, how to configure pgx driver not to use prepared statements maybe can check here, could you please help fix it and then can support pgbouncer transaction mode, thanks

yinan8128 avatar Aug 05 '22 03:08 yinan8128

Hello,

Thanks for your request.

pgwatch2 doesn't use `pgx but thanks anyway. Would you add some logs for clarifications? I'm afraid I don't understand the screenshot completely.

Thanks in advance!

pashagolub avatar Aug 05 '22 08:08 pashagolub

Hello,

Thank you for your reply

pgbouncer_pools_client_maxwait_seconds is a metric of prometheus-pgbouncer-exporter which means "How long the first (oldest) client in queue has waited, in seconds (labels: database, user)", now the metric showed that 120 seconds sometimes

This problem's root caused is using pgbouncer session mode, as pgbouncer transaction mode is much more efficient than pgbouncer session mode, could you please update the driver to support pgbouncer transaction mode please?

Thank you

yinan8128 avatar Aug 08 '22 03:08 yinan8128

Hey,

We plan to switch to the pgx library in the new major version. However, I cannot provide you with any timeline, unfortunately.

Seems like there is no solution I'm aware of for the current lib/pq library used.

pashagolub avatar Aug 10 '22 13:08 pashagolub

@pashagolub

Thank you for the information, any news for pgwatch2 use pgx library please? Thank you

yinan8128 avatar Apr 13 '23 09:04 yinan8128

Yes, we switched to pgx in the dev branch. However it's not public at the moment

pashagolub avatar Apr 13 '23 09:04 pashagolub