postgresql/src/include/storage
Andres Freund b19405a44b Fix bug leading to restoring unlogged relations from empty files.
At the end of crash recovery, unlogged relations are reset to the empty
state, using their init fork as the template. The init fork is copied to
the main fork without going through shared buffers. Unfortunately WAL
replay so far has not necessarily flushed writes from shared buffers to
disk at that point. In normal crash recovery, and before the
introduction of 'fast promotions' in fd4ced523 / 9.3, the
END_OF_RECOVERY checkpoint flushes the buffers out in time. But with
fast promotions that's not the case anymore.

To fix, force WAL writes targeting the init fork to be flushed
immediately (using the new FlushOneBuffer() function). In 9.5+ that
flush can centrally be triggered from the code dealing with restoring
full page writes (XLogReadBufferForRedoExtended), in earlier releases
that responsibility is in the hands of XLOG_HEAP_NEWPAGE's replay
function.

Backpatch to 9.1, even if this currently is only known to trigger in
9.3+. Flushing earlier is more robust, and it is advantageous to keep
the branches similar.

Typical symptoms of this bug are errors like
'ERROR:  index "..." contains unexpected zero page at block 0'
shortly after promoting a node.

Reported-By: Thom Brown
Author: Andres Freund and Michael Paquier
Discussion: 20150326175024.GJ451@alap3.anarazel.de
Backpatch: 9.1-
2015-12-10 16:29:27 +01:00
..
backendid.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
barrier.h Mark x86's memory barrier inline assembly as clobbering the cpu flags. 2014-09-19 17:13:52 +02:00
block.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
buf.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
buf_internals.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
buffile.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
bufmgr.h Fix bug leading to restoring unlogged relations from empty files. 2015-12-10 16:29:27 +01:00
bufpage.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
checksum.h Refactor checksumming code to make it easier to use externally. 2013-06-13 22:35:56 -04:00
checksum_impl.h Fix cpluspluscheck in checksum code 2013-06-30 19:34:14 -04:00
copydir.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
fd.h Fix fsync-at-startup code to not treat errors as fatal. 2015-05-28 17:33:03 -04:00
freespace.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
fsm_internals.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
indexfsm.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
ipc.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
item.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
itemid.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
itemptr.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
large_object.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
latch.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
lmgr.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
lock.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
lwlock.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
off.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
pg_sema.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04: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 copyrights for 2013 2013-01-01 17:15:01 -05:00
pos.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
predicate.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
predicate_internals.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
proc.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
procarray.h Ensure no xid gaps during Hot Standby startup 2013-06-23 11:09:24 +01:00
procsignal.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
reinit.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
relfilenode.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04: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
shmem.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
sinval.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
sinvaladt.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
smgr.h Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
spin.h Update copyrights for 2013 2013-01-01 17:15:01 -05:00
standby.h pgindent run for release 9.3 2013-05-29 16:58:43 -04:00