pgsql: Fix bug leading to restoring unlogged relations from empty files

Поиск
Список
Период
Сортировка
От Andres Freund
Тема pgsql: Fix bug leading to restoring unlogged relations from empty files
Дата
Msg-id E1a73U4-0002yZ-TY@gemulon.postgresql.org
обсуждение исходный текст
Ответы Re: pgsql: Fix bug leading to restoring unlogged relations from empty files  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-committers
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-

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/e3f4cfc7aa33f40b2b283676c9f0d5bf7ef08ccd

Modified Files
--------------
src/backend/access/transam/xlogutils.c |    9 +++++++++
src/backend/storage/buffer/bufmgr.c    |   21 +++++++++++++++++++++
src/include/storage/bufmgr.h           |    1 +
3 files changed, 31 insertions(+)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Accept flex > 2.5.x on Windows, too.
Следующее
От: Andres Freund
Дата:
Сообщение: pgsql: Fix ON CONFLICT UPDATE bug breaking AFTER UPDATE triggers.