Handle cancel requests with PID 0 gracefully
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 29 Jul 2025 21:39:49 +0000 (00:39 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 29 Jul 2025 21:40:15 +0000 (00:40 +0300)
commitfce7da1e73853b21a8084e645ac39354c1476261
tree918757a618639c1eda66bd992bc37cc367d5514a
parent8e5e3ff5564104b5e1c3c459d626967a702ad9fb
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
src/backend/storage/ipc/procsignal.c