pg.ddx.io  pgbouncer/pgbouncer GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgbouncer/pgbouncer] issue #1702: CancelRequest can use the wrong host from a host list
5+ messages / 2 participants
[nested] [flat]

* [pgbouncer/pgbouncer] issue #1702: CancelRequest can use the wrong host from a host list
@ 2026-11-13 05:01 "cosgroveb (@cosgroveb)" <noreply+cosgroveb@github.com>
  0 siblings, 0 replies; 5+ messages in thread

From: cosgroveb (@cosgroveb) @ 2026-11-13 05:01 UTC (permalink / raw)
  To: pgbouncer/pgbouncer <noreply+pgbouncer-pgbouncer@github.com>

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"; />


^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgbouncer/pgbouncer] issue #1702: CancelRequest can use the wrong host from a host list
@ 2026-11-13 05:38 ` "cosgroveb (@cosgroveb)" <noreply+cosgroveb@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: cosgroveb (@cosgroveb) @ 2026-11-13 05:38 UTC (permalink / raw)
  To: pgbouncer/pgbouncer <noreply+pgbouncer-pgbouncer@github.com>

This might be #1217 but I can't be sure from the issue alone.

^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgbouncer/pgbouncer] issue #1702: CancelRequest can use the wrong host from a host list
@ 2026-11-16 12:46 ` "ritojoao (@ritojoao)" <noreply+ritojoao@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: ritojoao (@ritojoao) @ 2026-11-16 12:46 UTC (permalink / raw)
  To: pgbouncer/pgbouncer <noreply+pgbouncer-pgbouncer@github.com>

Hi, I looked at this and think the cause is that `dns_connect()` advances the round-robin counter for the cancel connection, so the cancel goes to the next host in the list. I opened a PR with a fix and the test results: https://github.com/pgbouncer/pgbouncer/pull/1710. I reproduced it with two servers (3 of 6 cancels failed before, 0 of 6 after). It may also be related to #1217, but I did not test that. Feedback is welcome.


^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgbouncer/pgbouncer] issue #1702: CancelRequest can use the wrong host from a host list
@ 2026-11-17 18:21 ` "cosgroveb (@cosgroveb)" <noreply+cosgroveb@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: cosgroveb (@cosgroveb) @ 2026-11-17 18:21 UTC (permalink / raw)
  To: pgbouncer/pgbouncer <noreply+pgbouncer-pgbouncer@github.com>

> I opened a PR with a fix and the test results: #1710.

For future context, @ritojoao and I agreed in [the discussion on #1710](https://github.com/pgbouncer/pgbouncer/pull/1710#issuecomment-6951636745) to combine our fixes in #1703, with
shared co-author credit.


^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgbouncer/pgbouncer] issue #1702: CancelRequest can use the wrong host from a host list
@ 2026-11-17 18:21 ` "cosgroveb (@cosgroveb)" <noreply+cosgroveb@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: cosgroveb (@cosgroveb) @ 2026-11-17 18:21 UTC (permalink / raw)
  To: pgbouncer/pgbouncer <noreply+pgbouncer-pgbouncer@github.com>

@cosgroveb closed this.

^ permalink  raw  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2026-11-17 18:21 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 05:01 [pgbouncer/pgbouncer] issue #1702: CancelRequest can use the wrong host from a host list "cosgroveb (@cosgroveb)" <noreply+cosgroveb@github.com>
2026-11-13 05:38 ` "cosgroveb (@cosgroveb)" <noreply+cosgroveb@github.com>
2026-11-16 12:46 ` "ritojoao (@ritojoao)" <noreply+ritojoao@github.com>
2026-11-17 18:21 ` "cosgroveb (@cosgroveb)" <noreply+cosgroveb@github.com>
2026-11-17 18:21 ` "cosgroveb (@cosgroveb)" <noreply+cosgroveb@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