pgsql: In WAL replay, restore GIN metapage unconditionally to avoid tor

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: In WAL replay, restore GIN metapage unconditionally to avoid tor
Date: 2014-03-12 12:52:14
Message-ID: E1WNidq-0003Yk-Dq@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

In WAL replay, restore GIN metapage unconditionally to avoid torn page.

We don't take a full-page image of the GIN metapage; instead, the WAL record
contains all the information required to reconstruct it from scratch. But
to avoid torn page hazards, we must re-initialize it from the WAL record
every time, even if it already has a greater LSN, similar to how normal full
page images are restored.

This was highly unlikely to cause any problems in practice, because the GIN
metapage is small. We rely on an update smaller than a 512 byte disk sector
to be atomic elsewhere, at least in pg_control. But better safe than sorry,
and this would be easy to overlook if more fields are added to the metapage
so that it's no longer small.

Reported by Noah Misch. Backpatch to all supported versions.

Branch
------
REL8_4_STABLE

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

Modified Files
--------------
src/backend/access/gin/ginxlog.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-03-12 15:52:58 pgsql: Allow opclasses to provide tri-valued GIN consistent functions.
Previous Message Tom Lane 2014-03-10 19:47:52 pgsql: Fix tracking of psql script line numbers during \copy from anoth