pg.ddx.io  pgbouncer/pgbouncer GitHub issues and pull requests  
help / color / mirror / Atom feed
From: cosgroveb (@cosgroveb) <noreply+cosgroveb@github.com>
To: pgbouncer/pgbouncer <noreply+pgbouncer-pgbouncer@github.com>
Subject: [pgbouncer/pgbouncer] issue #1702: CancelRequest can use the wrong host from a host list
Date: Fri, 13 Nov 2026 05:01:02 +0000
Message-ID: <gh-pgbouncer-pgbouncer-1702@github.com> (raw)

I saw this when tracing through peer cancellation forwarding for #1700.

PgBouncer can send a query cancellation to a different PostgreSQL instance than the query backend when a database uses a comma-separated `host=` list and the default round-robin.

PgBouncer: `master`
OS: `Ubuntu 24.04.3 LTS`
PostgreSQL: `16.14`

```ini
[databases]
cancel_hostlist = port=55432 host=127.0.0.1,127.0.0.2 dbname=p0 user=bouncer pool_mode=session
```

Run two Postgres servers e.g. one on `127.0.0.1:55432` and one on `127.0.0.2:55432`, then connect through pgb:

```sh
psql 'host=127.0.0.1 port=55433 dbname=cancel_hostlist user=postgres'
```

Run `SELECT pg_sleep(3);` and press Ctrl-C.

Expected: `ERROR: canceling statement due to user request`.

Actual: psql reports `Cancel request sent`, but the query completes after three seconds.

```text
query backend       127.0.0.1
cancel socket       127.0.0.2
PgBouncer says: successfully sent cancel request
```

The cancel key belongs to the backend on `127.0.0.1`, but PgBouncer opens the cancellation connection to `127.0.0.2`. Attached a gif demonstrating this.

<img width="1672" height="1174" alt="rexbeta-2026-11-12-223006-trimmed-annotated" src="https://github.com/user-attachments/assets/4f92055e-17c3-4fa3-ae54-2f6fe9d8402b"; />


view thread (5+ messages)  latest in thread

Message-ID: <gh-pgbouncer-pgbouncer-1702@github.com>
Permalink:  ../gh-pgbouncer-pgbouncer-1702@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