pg.ddx.io  pgbouncer/pgbouncer GitHub issues and pull requests  
help / color / mirror / Atom feed
From: ritojoao (@ritojoao) <noreply+ritojoao@github.com>
To: pgbouncer/pgbouncer <noreply+pgbouncer-pgbouncer@github.com>
Subject: Re: [pgbouncer/pgbouncer] issue #715: Concurrent use of RESUME with PAUSE makes PAUSE hang permanently
Date: Sat, 14 Nov 2026 16:15:44 +0000
Message-ID: <gh-pgbouncer-pgbouncer-715-c6880469566@github.com> (raw)
In-Reply-To: <gh-pgbouncer-pgbouncer-715@github.com>
References: <gh-pgbouncer-pgbouncer-715@github.com>

Hi, and thanks for the detailed report.

I was able to reproduce this on 1.26.1 (current master, ac3bb6d) with three psql sessions: session 1 runs `SELECT pg_sleep(8)` on the database, session 2 runs `PAUSE test_db` on the console, and session 3 runs `RESUME test_db`. RESUME returns right away, and after session 1 finishes, session 2 never gets an answer.

From the code, `admin_cmd_pause()` sets `db_paused` and, if the database still has active servers, leaves the admin client with `wait_for_response = true`. The only place that answers it is `admin_pause_done()`, called from `per_loop_maint()` while a pause is in effect. Once `RESUME` clears `db_paused` (or `cf_pause_mode`), that condition is not true anymore, so the waiting admin is never answered.

I tried a small change: `admin_cmd_resume()` also answers any admin client still waiting for a PAUSE with an error, `PAUSE cancelled by RESUME`. It uses a separate flag so clients waiting for WAIT_CLOSE are not touched. With it, session 2 gets that error as soon as RESUME runs. It is about 23 added lines in `admin.c` and `bouncer.h`, and it avoids locking or counting pause requests. It is only a first idea: it wakes every waiting PAUSE on any RESUME, so with two databases paused it would also cancel a waiter whose database is still paused.

I also tried pressing ^C on a waiting PAUSE, on master only. With `PAUSE test_db`, the database stays paused and new clients block. With a global `PAUSE`, new clients can connect, but the psql that ran PAUSE never returned in my test. The change above does not cover ^C, and I have not added a regression test or run the pytest suite yet.

Would you be open to a PR along these lines? I am happy to change the approach if you had something different in mind.


view thread (6+ messages)  latest in thread

Message-ID: <gh-pgbouncer-pgbouncer-715-c6880469566@github.com>
Permalink:  ../gh-pgbouncer-pgbouncer-715-c6880469566@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox