postgresql/src
Tom Lane 2b196f01ef Fix transient clobbering of shared buffers during WAL replay.
RestoreBkpBlocks was in the habit of zeroing and refilling the target
buffer; which was perfectly safe when the code was written, but is unsafe
during Hot Standby operation.  The reason is that we have coding rules
that allow backends to continue accessing a tuple in a heap relation while
holding only a pin on its buffer.  Such a backend could see transiently
zeroed data, if WAL replay had occasion to change other data on the page.
This has been shown to be the cause of bug #6425 from Duncan Rance (who
deserves kudos for developing a sufficiently-reproducible test case) as
well as Bridget Frey's re-report of bug #6200.  It most likely explains the
original report as well, though we don't yet have confirmation of that.

To fix, change the code so that only bytes that are supposed to change will
change, even transiently.  This actually saves cycles in RestoreBkpBlocks,
since it's not writing the same bytes twice.

Also fix seq_redo, which has the same disease, though it has to work a bit
harder to meet the requirement.

So far as I can tell, no other WAL replay routines have this type of bug.
In particular, the index-related replay routines, which would certainly be
broken if they had to meet the same standard, are not at risk because we
do not have coding rules that allow access to an index page when not
holding a buffer lock on it.

Back-patch to 9.0 where Hot Standby was added.
2012-02-05 15:49:46 -05:00
..
backend Fix transient clobbering of shared buffers during WAL replay. 2012-02-05 15:49:46 -05:00
bin Fix pg_restore's direct-to-database mode for INSERT-style table data. 2012-01-06 13:04:24 -05:00
include Resolve timing issue with logging locks for Hot Standby. 2012-02-01 09:33:16 +00:00
interfaces In ecpg removed old leftover check for given connection name. 2011-12-18 18:46:00 +01:00
makefiles Fix assorted issues with build and install paths containing spaces. 2011-06-14 16:41:23 -04:00
pl Translation updates 2011-12-01 22:59:40 +02:00
port Stamp 9.0.6. 2011-12-01 16:49:59 -05:00
template Don't try to force use of -no-cpp-precomp on OS X. It's been five years 2010-08-02 04:51:25 +00:00
test Make executor's SELECT INTO code save and restore original tuple receiver. 2012-01-04 18:31:08 -05:00
timezone Update time zone data files to tzdata release 2011n. 2011-11-30 11:48:36 -05:00
tools Backpatch "Use the preferred version of xsubpp." 2011-11-28 07:54:03 -05:00
tutorial Remove copyright mention of Andrew Yu, per author's permission. 2010-02-02 18:52:02 +00:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:06 +02:00
bcc32.mak Remove old-style win32 client-only visual c++ build infrastructure for everything except 2007-03-05 14:18:38 +00: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 Rethink the way walreceiver is linked into the backend. Instead than shoving 2010-01-20 09:16:24 +00:00
Makefile.global.in Accept slightly grotty coding in Makefile.global in order to keep the -L 2010-07-06 22:03:05 +00:00
Makefile.shlib Fix assorted issues with build and install paths containing spaces. 2011-06-14 16:41:23 -04:00
nls-global.mk Avoid error from mkdir if no languages are to be installed 2010-05-13 14:35:28 +00:00
win32.mak Update supported standalone VC++ version to 7.1+ only, and fix 2007-08-03 10:47:11 +00:00