postgresql/src/backend/storage
Tom Lane 887feefe87 Don't CHECK_FOR_INTERRUPTS between WaitLatch and ResetLatch.
This coding pattern creates a race condition, because if an interesting
interrupt happens after we've checked InterruptPending but before we reset
our latch, the latch-setting done by the signal handler would get lost,
and then we might block at WaitLatch in the next iteration without ever
noticing the interrupt condition.  You can put the CHECK_FOR_INTERRUPTS
before WaitLatch or after ResetLatch, but not between them.

Aside from fixing the bugs, add some explanatory comments to latch.h
to perhaps forestall the next person from making the same mistake.

In HEAD, also replace gather_readnext's direct call of
HandleParallelMessages with CHECK_FOR_INTERRUPTS.  It does not seem clean
or useful for this one caller to bypass ProcessInterrupts and go straight
to HandleParallelMessages; not least because that fails to consider the
InterruptPending flag, resulting in useless work both here
(if InterruptPending isn't set) and in the next CHECK_FOR_INTERRUPTS call
(if it is).

This thinko seems to have been introduced in the initial coding of
storage/ipc/shm_mq.c (commit ec9037df2), and then blindly copied into all
the subsequent parallel-query support logic.  Back-patch relevant hunks
to 9.4 to extirpate the error everywhere.

Discussion: <1661.1469996911@sss.pgh.pa.us>
2016-08-01 15:13:53 -04:00
..
buffer Improve WritebackContextInit() comment and prototype argument names. 2016-07-01 14:29:03 -07:00
file Widen amount-to-flush arguments of FileWriteback and callers. 2016-04-13 18:12:06 -04:00
freespace pgindent run for 9.6 2016-06-09 18:02:36 -04:00
ipc Don't CHECK_FOR_INTERRUPTS between WaitLatch and ResetLatch. 2016-08-01 15:13:53 -04:00
large_object Update copyright for 2016 2016-01-02 13:33:40 -05:00
lmgr Finish pgindent run for 9.6: Perl files. 2016-06-12 04:19:56 -04:00
page Fix PageAddItem BRIN bug 2016-05-30 14:47:22 -04:00
smgr Fix various common mispellings. 2016-06-03 16:08:45 +01:00
Makefile Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00