aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/transam.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-06-21 23:04:40 -0400
committerRobert Haas <rhaas@postgresql.org>2011-06-21 23:04:40 -0400
commit503c7305a1e379f95649eef1a694d0c1dbdc674a (patch)
tree39bb67975f3419f76d6973e86d5517c8e55f9853 /src/backend/access/transam/transam.c
parent431ab0e82819b31fcd1e33ecb52c2cd3b4b41da7 (diff)
downloadpostgresql-503c7305a1e379f95649eef1a694d0c1dbdc674a.tar.gz
postgresql-503c7305a1e379f95649eef1a694d0c1dbdc674a.zip
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.
Diffstat (limited to 'src/backend/access/transam/transam.c')
-rw-r--r--src/backend/access/transam/transam.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index bc02f15e868..472dd4cca6e 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -24,6 +24,8 @@
#include "access/transam.h"
#include "utils/snapmgr.h"
+/* Handy constant for an invalid xlog recptr */
+const XLogRecPtr InvalidXLogRecPtr = {0, 0};
/*
* Single-item cache for results of TransactionLogFetch. It's worth having
@@ -35,9 +37,6 @@ static TransactionId cachedFetchXid = InvalidTransactionId;
static XidStatus cachedFetchXidStatus;
static XLogRecPtr cachedCommitLSN;
-/* Handy constant for an invalid xlog recptr */
-static const XLogRecPtr InvalidXLogRecPtr = {0, 0};
-
/* Local functions */
static XidStatus TransactionLogFetch(TransactionId transactionId);