0

We have a Postgres and PgBouncer setup and use SIGINT for graceful termination based on the pgbouncer docs:

SIGINT Safe shutdown. Same as issuing PAUSE and SHUTDOWN on the console.

The pre stop hook script looks like this:

kill -INT 1; sleep 270;

But pgbouncer sometimes can't quit in time and some inserts and other possible commands are dropped causing data integrity issues.

Does anyone know a good way to debug this? Are we able to log hang queries or anything like this?

wwang
  • 59
  • 3

1 Answers1

1

Look into pg_stat_activity for sessions that are "idle in transaction" (if you use transaction pooling mode) or "idle" (if you use session pooling mode). Smart shutdown won't stop pgBouncer until the last such session goes away on its own accord.

If killing a client session causes data integrity problems, your transaction management is buggy, and you would face the same problems in the case of a crash or network outage.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263