pgsql: Fix WAL-logging of FSM and VM truncation.

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix WAL-logging of FSM and VM truncation.
Date: 2016-10-19 12:01:33
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix WAL-logging of FSM and VM truncation.

When a relation is truncated, it is important that the FSM is truncated as
well. Otherwise, after recovery, the FSM can return a page that has been
truncated away, leading to errors like:

ERROR: could not read block 28991 in file "base/16390/572026": read only 0
of 8192 bytes

We were using MarkBufferDirtyHint() to dirty the buffer holding the last
remaining page of the FSM, but during recovery, that might in fact not
dirty the page, and the FSM update might be lost.

To fix, use the stronger MarkBufferDirty() function. MarkBufferDirty()
requires us to do WAL-logging ourselves, to protect from a torn page, if
checksumming is enabled.

Also fix an oversight in visibilitymap_truncate: it also needs to WAL-log
when checksumming is enabled.

Analysis by Pavan Deolasee.

Discussion: <CABOikdNr5vKucqyZH9s1Mh0XebLs_jRhKv6eJfNnD2wxTn=_9A(at)mail(dot)gmail(dot)com>

Backpatch to 9.3, where we got data checksums.

Branch
------
REL9_5_STABLE

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

Modified Files
--------------
src/backend/access/heap/visibilitymap.c | 16 ++++++++++++++++
src/backend/storage/freespace/freespace.c | 21 ++++++++++++++++++++-
2 files changed, 36 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2016-10-19 12:50:07 pgsql: pg_ctl: Add long options for -w and -W
Previous Message Heikki Linnakangas 2016-10-19 11:29:23 pgsql: Fix WAL-logging of FSM and VM truncation.