pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Handle cancel requests with PID 0 gracefully
Date: Tue, 29 Jul 2025 21:51:48 +0000
Message-ID: <E1ugsEd-001NGD-2W@gemulon.postgresql.org> (raw)

Handle cancel requests with PID 0 gracefully

If the client sent a query cancel request with backend PID 0, it
tripped an assertion. With assertions disabled, you got this in the
log instead:

    LOG:  invalid cancel request with PID 0
    LOG:  wrong key in cancel request for process 0

Query cancellations don't even require authentication, so we better
tolerate bogus requests. Fix by turning the assertion into a regular
runtime check.

Spotted while testing libpq behavior with a modified server that
didn't send BackendKeyData to the client.

Backpatch-through: 18

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/fce7da1e73853b21a8084e645ac39354c1476261

Modified Files
--------------
src/backend/storage/ipc/procsignal.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)



view thread (2+ messages)

Message-ID: <E1ugsEd-001NGD-2W@gemulon.postgresql.org>
Permalink:  ../E1ugsEd-001NGD-2W@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ugsEd-001NGD-2W@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Handle cancel requests with PID 0 gracefully
  In-Reply-To: <E1ugsEd-001NGD-2W@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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