From: | Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Fix race condition between hot standby and restoring a full-page |
Date: | 2014-11-13 18:18:39 |
Message-ID: | E1Xoyyd-0007XW-I1@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix race condition between hot standby and restoring a full-page image.
There was a window in RestoreBackupBlock where a page would be zeroed out,
but not yet locked. If a backend pinned and locked the page in that window,
it saw the zeroed page instead of the old page or new page contents, which
could lead to missing rows in a result set, or errors.
To fix, replace RBM_ZERO with RBM_ZERO_AND_LOCK, which atomically pins,
zeroes, and locks the page, if it's not in the buffer cache already.
In stable branches, the old RBM_ZERO constant is renamed to RBM_DO_NOT_USE,
to avoid breaking any 3rd party extensions that might use RBM_ZERO. More
importantly, this avoids renumbering the other enum values, which would
cause even bigger confusion in extensions that use ReadBufferExtended, but
haven't been recompiled.
Backpatch to all supported versions; this has been racy since hot standby
was introduced.
Branch
------
REL9_3_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/861d3aa43d2f38f19773cf4636937837bb0c2167
Modified Files
--------------
src/backend/access/hash/hashpage.c | 13 +++++-----
src/backend/access/heap/heapam.c | 3 +--
src/backend/access/transam/xlog.c | 6 +----
src/backend/access/transam/xlogutils.c | 17 +++++++++----
src/backend/storage/buffer/bufmgr.c | 41 ++++++++++++++++++++++++++++----
src/include/storage/bufmgr.h | 11 ++++++---
6 files changed, 66 insertions(+), 25 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2014-11-13 19:43:52 | pgsql: Fix xmin/xmax horizon computation during logical decoding initia |
Previous Message | Alvaro Herrera | 2014-11-13 17:46:42 | pgsql: Tweak row-level locking documentation |