pgsql: Fix transient clobbering of shared buffers during WAL replay.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix transient clobbering of shared buffers during WAL replay.
Дата
Msg-id E1Ru93F-0002h1-IP@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/17118825b8164aac6d337b58cf66b17637c66a49

Modified Files
--------------
src/backend/access/transam/xlog.c |    4 ++--
src/backend/commands/sequence.c   |   29 ++++++++++++++++++++++-------
2 files changed, 24 insertions(+), 9 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix transient clobbering of shared buffers during WAL replay.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix transient clobbering of shared buffers during WAL replay.