Re: BackendKeyData is mandatory?
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Jelte Fennema-Nio <postgres@jeltef.nl>
Cc: Tom Lane <tgl@sss.pgh.pa.us>,
Jacob Champion <jacob.champion@enterprisedb.com>,
Tatsuo Ishii <ishii@postgresql.org>, peter@eisentraut.org,
pgsql-hackers@postgresql.org, Dave Cramer <davecramer@gmail.com>
Date: 2025-08-22T11:56:35Z
Lists: pgsql-hackers
On 19/08/2025 23:49, Jelte Fennema-Nio wrote: > On Thu, 14 Aug 2025 at 15:10, Heikki Linnakangas <hlinnaka@iki.fi> wrote: >> Here's a new set of patches, to disconnect on OOM instead of hanging or >> silently discarding messages: > > Code looks good. Som small nitpicks though. > > This change seems unnecessary, i.e. free(NULL) is a no-op > > - free(svname); > + if (svname) > + free(svname); And even more so, this is unreachable when svname == NULL. Thanks! > Small wording suggestion, maybe change this: > > The caller has already saved the error message in conn->errorMessage. > > to > > The caller should have already saved the error message in conn->errorMessage. > > or even > > The caller should have already saved the error message using > libpq_append_conn_error. I kept it as is, because we use similar wording in a few other places. Some places do write the message directly in conn->errorMessage without using libpq_append_conn_error. Pushed and backpatched to v18. I feel the OOM handling commit would be appropriate to backpatch further, but since it's pretty intricate code and we haven't gotten any complaints from the field, I only backpatched it to v18 for now. We can backpatch it further later if needed. Thanks for the original patch and the review! - Heikki
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