pgsql: Make the visibility map crash-safe. - Mailing list pgsql-committers

From Robert Haas
Subject pgsql: Make the visibility map crash-safe.
Date
Msg-id E1QZDlN-0000z9-21@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Robert Haas
Date:
Subject: pgsql: Add some regression tests for serial pseudotypes.
Next
From: Heikki Linnakangas
Date:
Subject: pgsql: Remove pointless const qualifiers from function arguments in the