pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Server-side fix for delayed NOTIFY and SIGTERM processing. 5+ messages / 1 participants [nested] [flat]
* pgsql: Server-side fix for delayed NOTIFY and SIGTERM processing. @ 2018-10-20 02:23 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2018-10-20 02:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/2ddb9149d14de9a2e7ac9ec6accf3ad442702b24 Modified Files -------------- src/backend/libpq/be-secure.c | 20 ++++++----- src/backend/tcop/postgres.c | 77 ++++++++++++++++++++++++++++--------------- 2 files changed, 62 insertions(+), 35 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Server-side fix for delayed NOTIFY and SIGTERM processing. @ 2018-10-20 02:23 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2018-10-20 02:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7aaeb7b45ac7944ae09fcc9d3a2b58d2fdbefa87 Modified Files -------------- src/backend/libpq/be-secure.c | 20 ++++++----- src/backend/tcop/postgres.c | 77 ++++++++++++++++++++++++++++--------------- 2 files changed, 62 insertions(+), 35 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Server-side fix for delayed NOTIFY and SIGTERM processing. @ 2018-10-20 02:23 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2018-10-20 02:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3bdef6d211314842ad8d2415287013ddc3314024 Modified Files -------------- src/backend/libpq/be-secure.c | 20 ++++++----- src/backend/tcop/postgres.c | 77 ++++++++++++++++++++++++++++--------------- 2 files changed, 62 insertions(+), 35 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Server-side fix for delayed NOTIFY and SIGTERM processing. @ 2018-10-20 02:23 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2018-10-20 02:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/cbab94077e126bf32d5fb47695d7a43fe7cb60ac Modified Files -------------- src/backend/libpq/be-secure.c | 20 ++++++----- src/backend/tcop/postgres.c | 77 ++++++++++++++++++++++++++++--------------- 2 files changed, 62 insertions(+), 35 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Server-side fix for delayed NOTIFY and SIGTERM processing. @ 2018-10-20 02:23 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2018-10-20 02:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f4941666afc6ed8cf29fa8e89b089b8a3443485f Modified Files -------------- src/backend/libpq/be-secure.c | 20 ++++++----- src/backend/tcop/postgres.c | 77 ++++++++++++++++++++++++++++--------------- 2 files changed, 62 insertions(+), 35 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2018-10-20 02:23 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2018-10-20 02:23 pgsql: Server-side fix for delayed NOTIFY and SIGTERM processing. Tom Lane <tgl@sss.pgh.pa.us> 2018-10-20 02:23 pgsql: Server-side fix for delayed NOTIFY and SIGTERM processing. Tom Lane <tgl@sss.pgh.pa.us> 2018-10-20 02:23 pgsql: Server-side fix for delayed NOTIFY and SIGTERM processing. Tom Lane <tgl@sss.pgh.pa.us> 2018-10-20 02:23 pgsql: Server-side fix for delayed NOTIFY and SIGTERM processing. Tom Lane <tgl@sss.pgh.pa.us> 2018-10-20 02:23 pgsql: Server-side fix for delayed NOTIFY and SIGTERM processing. Tom Lane <tgl@sss.pgh.pa.us>
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