postgresql/src
Andres Freund 86b9424e86 Prevent potentially hazardous compiler/cpu reordering during lwlock release.
In LWLockRelease() (and in 9.4+ LWLockUpdateVar()) we release enqueued
waiters using PGSemaphoreUnlock(). As there are other sources of such
unlocks backends only wake up if MyProc->lwWaiting is set to false;
which is only done in the aforementioned functions.

Before this commit there were dangers because the store to lwWaitLink
could become visible before the store to lwWaitLink. This could both
happen due to compiler reordering (on most compilers) and on some
platforms due to the CPU reordering stores.

The possible consequence of this is that a backend stops waiting
before lwWaitLink is set to NULL. If that backend then tries to
acquire another lock and has to wait there the list could become
corrupted once the lwWaitLink store is finally performed.

Add a write memory barrier to prevent that issue.

Unfortunately the barrier support has been only added in 9.2. Given
that the issue has not knowingly been observed in praxis it seems
sufficient to prohibit compiler reordering using volatile for 9.0 and
9.1. Actual problems due to compiler reordering are more likely
anyway.

Discussion: 20140210134625.GA15246@awork2.anarazel.de
2014-12-19 14:55:54 +01:00
..
backend Prevent potentially hazardous compiler/cpu reordering during lwlock release. 2014-12-19 14:55:54 +01:00
bin Give a proper error message if initdb password file is empty. 2014-12-05 14:31:37 +02:00
include Fix off-by-one loop count in MapArrayTypeName, and get rid of static array. 2014-12-16 15:35:46 -05:00
interfaces Fix minor bugs in commit 30bf4689a9 et al. 2014-11-30 12:20:57 -05:00
makefiles Don't use deprecated dllwrap on Cygwin. 2014-02-01 16:14:01 -05:00
pl Translation updates 2014-07-21 00:58:58 -04:00
port Suppress dead, unportable src/port/crypt.c code. 2014-10-12 23:27:30 -04:00
template Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
test Lock down regression testing temporary clusters on Windows. 2014-12-17 22:48:47 -05:00
timezone Update time zone data files to tzdata release 2014j. 2014-11-17 12:08:39 -05:00
tools Recognize Makefile line continuations in fetchRegressOpts(). 2014-12-18 03:57:48 -05:00
tutorial Remove tabs after spaces in C comments 2014-05-06 11:26:26 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix some oversights in distprep and maintainer-clean targets. 2011-03-10 00:04:05 -05:00
Makefile.global.in Revert "Backpatch pgxs vpath build and installation fixes (v2)" 2013-10-07 22:39:30 -04:00
Makefile.shlib fix whitespace 2014-02-01 16:30:14 -05:00
nls-global.mk Fix makefile logic to not break the build when xgettext is missing 2010-10-14 23:16:46 +03:00
win32.mak Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00