postgresql/src
Alvaro Herrera c618796404 Change some bogus PageGetLSN calls to BufferGetLSNAtomic
As src/backend/access/transam/README says, PageGetLSN may only be called
by processes holding either exclusive lock on buffer, or a shared lock
on buffer plus buffer header lock.  Therefore any place that only holds
a shared buffer lock must use BufferGetLSNAtomic instead of PageGetLSN,
which internally obtains buffer header lock prior to reading the LSN.

A few callsites failed to comply with this rule.  This was detected by
running all tests under a new (not committed) assertion that verifies
PageGetLSN locking contract.  All but one of the callsites that failed
the assertion are fixed by this patch.  Remaining callsites were
inspected manually and determined not to need any change.

The exception (unfixed callsite) is in TestForOldSnapshot, which only
has a Page argument, making it impossible to access the corresponding
Buffer from it.  Fixing that seems a much larger patch that will have to
be done separately; and that's just as well, since it was only
introduced in 9.6 and other bugs are much older.

Some of these bugs are ancient; backpatch all the way back to 9.3.

Authors: Jacob Champion, Asim Praveen, Ashwin Agrawal
Reviewed-by: Michaël Paquier
Discussion: https://postgr.es/m/CABAq_6GXgQDVu3u12mK9O5Xt5abBZWQ0V40LZCE+oUf95XyNFg@mail.gmail.com
2018-01-09 17:07:24 -03:00
..
backend Change some bogus PageGetLSN calls to BufferGetLSNAtomic 2018-01-09 17:07:24 -03:00
bin Translation updates 2017-11-05 17:04:00 -05:00
common Unlink static libraries before rebuilding them. 2015-03-01 13:06:33 -05:00
include Fix failure to delete spill files of aborted transactions 2018-01-05 12:17:10 -03:00
interfaces Add post-2010 ecpg tests to checktcp. 2017-11-11 14:41:50 -08:00
makefiles Always use -fPIC, not -fpic, when building shared libraries with gcc. 2017-06-01 13:32:56 -04:00
pl Support linking with MinGW-built Perl. 2017-11-23 20:29:48 -08:00
port Stamp 9.4.15. 2017-11-06 17:13:17 -05:00
template AIX: Test the -qlonglong option before use. 2015-07-17 03:01:35 -04:00
test Fix deadlock hazard in CREATE INDEX CONCURRENTLY 2018-01-02 19:16:16 -03:00
timezone Replace raw timezone source data with IANA's new compact format. 2017-11-25 15:30:44 -05:00
tools Fix use of config-specific libraries for Windows OpenSSL 2018-01-03 15:34:02 -05:00
tutorial pgindent run for 9.4 2014-05-06 12:12:18 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04: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 Install TAP test infrastructure so it's available for extension testing. 2016-09-23 15:50:00 -04:00
Makefile.global.in PL/Perl portability fix: absorb relevant -D switches from Perl. 2017-07-31 12:38:35 -04:00
Makefile.shlib Fix typos in comments. 2017-02-06 11:34:24 +02:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00