pgsql: Make the visibility map crash-safe.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Make the visibility map crash-safe.
Date: 2011-06-22 03:05:57
Message-ID: E1QZDlN-0000z9-21@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Make the visibility map crash-safe.

This involves two main changes from the previous behavior. First,
when we set a bit in the visibility map, emit a new WAL record of type
XLOG_HEAP2_VISIBLE. Replay sets the page-level PD_ALL_VISIBLE bit and
the visibility map bit. Second, when inserting, updating, or deleting
a tuple, we can no longer get away with clearing the visibility map
bit after releasing the lock on the corresponding heap page, because
an intervening crash might leave the visibility map bit set and the
page-level bit clear. Making this work requires a bit of interface
refactoring.

In passing, a few minor but related cleanups: change the test in
visibilitymap_set and visibilitymap_clear to throw an error if the
wrong page (or no page) is pinned, rather than silently doing nothing;
this case should never occur. Also, remove duplicate definitions of
InvalidXLogRecPtr.

Patch by me, review by Noah Misch.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/503c7305a1e379f95649eef1a694d0c1dbdc674a

Modified Files
--------------
src/backend/access/heap/heapam.c | 263 ++++++++++++++++++++++++++++---
src/backend/access/heap/hio.c | 48 ++++++-
src/backend/access/heap/visibilitymap.c | 110 +++++++------
src/backend/access/transam/transam.c | 5 +-
src/backend/access/transam/xlog.c | 3 -
src/backend/commands/vacuumlazy.c | 8 +-
src/include/access/heapam.h | 2 +
src/include/access/hio.h | 3 +-
src/include/access/htup.h | 10 ++
src/include/access/transam.h | 3 +
src/include/access/visibilitymap.h | 6 +-
src/include/access/xlog_internal.h | 2 +-
12 files changed, 373 insertions(+), 90 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2011-06-22 09:25:17 pgsql: Remove pointless const qualifiers from function arguments in the
Previous Message Robert Haas 2011-06-22 02:58:02 pgsql: Add some regression tests for serial pseudotypes.

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-06-22 03:10:53 Re: pg_upgrade using appname to lock out other users
Previous Message Bruce Momjian 2011-06-22 03:05:17 Indication of db-shared tables