]> granicus.if.org Git - postgresql/commit
Server-side fix for delayed NOTIFY and SIGTERM processing.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 20 Oct 2018 01:39:21 +0000 (21:39 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 20 Oct 2018 01:39:21 +0000 (21:39 -0400)
commit2ddb9149d14de9a2e7ac9ec6accf3ad442702b24
tree41dbed01032da06d1943a4a5dbb1c06ae1508b94
parent12bfb778ce688fc662a6cb35f6298734fcf4856f
Server-side fix for delayed NOTIFY and SIGTERM processing.

Commit 4f85fde8e introduced some code that was meant to ensure that we'd
process cancel, die, sinval catchup, and notify interrupts while waiting
for client input.  But there was a flaw: it supposed that the process
latch would be set upon arrival at secure_read() if any such interrupt
was pending.  In reality, we might well have cleared the process latch
at some earlier point while those flags remained set -- particularly
notifyInterruptPending, which can't be handled as long as we're within
a transaction.

To fix the NOTIFY case, also attempt to process signals (except
ProcDiePending) before trying to read.

Also, if we see that ProcDiePending is set before we read, forcibly set the
process latch to ensure that we will handle that signal promptly if no data
is available.  I also made it set the process latch on the way out, in case
there is similar logic elsewhere.  (It remains true that we won't service
ProcDiePending here unless we need to wait for input.)

The code for handling ProcDiePending during a write needs those changes,
too.

Also be a little more careful about when to reset whereToSendOutput,
and improve related comments.

Back-patch to 9.5 where this code was added.  I'm not entirely convinced
that older branches don't have similar issues, but the complaint at hand
is just about the >= 9.5 code.

Jeff Janes and Tom Lane

Discussion: https://postgr.es/m/CAOYf6ec-TmRYjKBXLLaGaB-jrd=mjG1Hzn1a1wufUAR39PQYhw@mail.gmail.com
src/backend/libpq/be-secure.c
src/backend/tcop/postgres.c