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>, <tgl@sss.pgh.pa.us>, <hlinnaka@iki.fi>, <peter@eisentraut.org>, <pgsql-hackers@postgresql.org>
Date: 2025-06-25T07:12:05Z
Lists: pgsql-hackers

Attachments

On Tue Jun 24, 2025 at 5:07 PM CEST, Jacob Champion wrote:
> So that's
> 1) return an (empty) cancellation object even if the server has not
> sent a key, and
> 2) error out when trying to cancel with an empty object?
>
> That sounds reasonable to me.

Attached is an attempt at implementing the above. I did not test it
against these systems though.

I also added small commit that checks for the 256 byte key length limit
described in the protocol documentation. This thread made me remember
that we talked about that during PGConf.dev.

Commits

  1. Revert unnecessary check for NULL

  2. libpq: Be strict about cancel key lengths

  3. libpq: Handle OOM by disconnecting instead of hanging or skipping msgs

  4. libpq: Complain about missing BackendKeyData later with PGgetCancel()