postgresql/src/include/storage
Tom Lane 8ef3d9fae4 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
..
backendid.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
barrier.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
block.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
buf.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
buf_internals.h Align buffer descriptors to cache line boundaries. 2015-01-29 22:48:45 +01:00
buffile.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
bufmgr.h Fix bug leading to restoring unlogged relations from empty files. 2015-12-10 16:39:25 +01:00
bufpage.h Fix PageAddItem BRIN bug 2016-05-30 14:47:22 -04:00
checksum.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
checksum_impl.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
copydir.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
dsm.h Add flags argument to dsm_create. 2015-03-19 13:03:03 -04:00
dsm_impl.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
fd.h Introduce durable_rename() and durable_link_or_rename(). 2016-03-09 18:53:53 -08:00
freespace.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
fsm_internals.h Use FLEXIBLE_ARRAY_MEMBER in a bunch more places. 2015-02-20 00:11:42 -05:00
indexfsm.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
ipc.h Tweak __attribute__-wrapping macros for better pgindent results. 2015-03-26 14:03:25 -04:00
item.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
itemid.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
itemptr.h Improve packing/alignment annotation for ItemPointerData. 2015-05-21 17:21:46 -04:00
large_object.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
latch.h Don't CHECK_FOR_INTERRUPTS between WaitLatch and ResetLatch. 2016-08-01 15:13:53 -04:00
lmgr.h pgindent run for 9.5 2015-05-23 21:35:49 -04:00
lock.h pgindent run for 9.5 2015-05-23 21:35:49 -04:00
lwlock.h Rework the way multixact truncations work. 2015-09-26 19:04:25 +02:00
off.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
pg_sema.h Remove the option to service interrupts during PGSemaphoreLock(). 2015-02-03 23:25:00 +01:00
pg_shmem.h On Windows, ensure shared memory handle gets closed if not being used. 2015-10-13 11:21:33 -04:00
pmsignal.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
pos.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
predicate.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
predicate_internals.h Define integer limits independently from the system definitions. 2015-04-02 17:43:35 +02:00
proc.h Move deadlock and other interrupt handling in proc.c out of signal handlers. 2015-02-03 23:24:38 +01:00
procarray.h Create an infrastructure for parallel computation in PostgreSQL. 2015-04-30 15:02:14 -04:00
procsignal.h Create an infrastructure for parallel computation in PostgreSQL. 2015-04-30 15:02:14 -04:00
reinit.h reinit.h: Fix typo in identification comment 2015-01-22 12:26:51 -03:00
relfilenode.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
s_lock.h Fix s_lock.h PPC assembly code to be compatible with native AIX assembler. 2015-08-29 16:09:25 -04:00
shm_mq.h Don't send protocol messages to a shm_mq that no longer exists. 2015-10-16 09:49:08 -04:00
shm_toc.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
shmem.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
sinval.h Introduce and use infrastructure for interrupt processing during client reads. 2015-02-03 22:25:20 +01:00
sinvaladt.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
smgr.h Update copyright for 2015 2015-01-06 11:43:47 -05:00
spin.h Remove cautions about using volatile from spin.h. 2015-10-16 14:10:28 -04:00
standby.h Use FLEXIBLE_ARRAY_MEMBER in a bunch more places. 2015-02-20 00:11:42 -05:00