Re: BackendKeyData is mandatory?
Jelte Fennema-Nio <postgres@jeltef.nl>
From: Jelte Fennema-Nio <postgres@jeltef.nl>
To: Jacob Champion <jacob.champion@enterprisedb.com>
Cc: Tatsuo Ishii <ishii@postgresql.org>, hlinnaka@iki.fi,
peter@eisentraut.org, pgsql-hackers@postgresql.org
Date: 2025-06-23T16:23:53Z
Lists: pgsql-hackers
On Mon, 23 Jun 2025 at 18:02, Jacob Champion <jacob.champion@enterprisedb.com> wrote: > If anyone today is relying on "backend-key-less" connection, this is > potentially a breaking change. For example, psycopg2 now complains: > > psycopg2.OperationalError: can't get cancellation key It's not super clear what you're referring to with "this" in your first sentence. To be clear, I'm not saying we should start throwing errors for things in libpq that weren't errors before. But more as: I don't expect many client authors to have considered the scenario of no BackendKeyData. Because either an author believes the BackendKeyData is optional, in which case they shouldn't send a CancelRequest for those connections. Or they think it is required, in which case throwing an error seems like the sensible thing to do. And the implementations in PgBouncer and PG17 is neither, i.e. it won't throw an error, but instead of doing nothing it will do something clearly useless.
Commits
-
Revert unnecessary check for NULL
- 5a26a3e4eeb2 18.0 landed
- 807ee417e562 19 (unreleased) landed
-
libpq: Be strict about cancel key lengths
- e7ff96853ea7 18.0 landed
- e411a8d25a4b 19 (unreleased) landed
-
libpq: Handle OOM by disconnecting instead of hanging or skipping msgs
- 8aa287c9061b 18.0 landed
- f6f0542266f0 19 (unreleased) landed
-
libpq: Complain about missing BackendKeyData later with PGgetCancel()
- 42b1480eb2c6 18.0 landed
- a4801eb691ed 19 (unreleased) landed