aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-06-26 12:38:24 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-06-26 12:38:24 +0300
commit4b8e24b9ad308c30dbe2184e06848e638e018114 (patch)
tree75aa34a22d85cf402477a97991a1513de657dcc8
parentf7bb7f0625771bc71869cdadafcf54450b2db08f (diff)
downloadpostgresql-4b8e24b9ad308c30dbe2184e06848e638e018114.tar.gz
postgresql-4b8e24b9ad308c30dbe2184e06848e638e018114.zip
Fix a couple of bugs with wal_log_hints.
1. Replay of the WAL record for setting a bit in the visibility map contained an assertion that a full-page image of that record type can only occur with checksums enabled. But it can also happen with wal_log_hints, so remove the assertion. Unlike checksums, wal_log_hints can be changed on the fly, so it would be complicated to figure out if it was enabled at the time that the WAL record was generated. 2. wal_log_hints has the same effect on the locking needed to read the LSN of a page as data checksums. BufferGetLSNAtomic() didn't get the memo. Backpatch to 9.4, where wal_log_hints was added.
-rw-r--r--src/backend/access/heap/heapam.c15
-rw-r--r--src/backend/storage/buffer/bufmgr.c2
2 files changed, 9 insertions, 8 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index caacc105d25..208457584d9 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -7479,10 +7479,11 @@ heap_xlog_visible(XLogReaderState *record)
{
/*
* We don't bump the LSN of the heap page when setting the visibility
- * map bit (unless checksums are enabled, in which case we must),
- * because that would generate an unworkable volume of full-page
- * writes. This exposes us to torn page hazards, but since we're not
- * inspecting the existing page contents in any way, we don't care.
+ * map bit (unless checksums or wal_hint_bits is enabled, in which
+ * case we must), because that would generate an unworkable volume of
+ * full-page writes. This exposes us to torn page hazards, but since
+ * we're not inspecting the existing page contents in any way, we
+ * don't care.
*
* However, all operations that clear the visibility map bit *do* bump
* the LSN, and those operations will only be replayed if the XLOG LSN
@@ -7497,10 +7498,10 @@ heap_xlog_visible(XLogReaderState *record)
else if (action == BLK_RESTORED)
{
/*
- * If heap block was backed up, restore it. This can only happen with
- * checksums enabled.
+ * If heap block was backed up, we already restored it and there's
+ * nothing more to do. (This can only happen with checksums or
+ * wal_log_hints enabled.)
*/
- Assert(DataChecksumsEnabled());
}
if (BufferIsValid(buffer))
UnlockReleaseBuffer(buffer);
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index cc973b53a91..e4b25587e98 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -2496,7 +2496,7 @@ BufferGetLSNAtomic(Buffer buffer)
/*
* If we don't need locking for correctness, fastpath out.
*/
- if (!DataChecksumsEnabled() || BufferIsLocal(buffer))
+ if (!XLogHintBitIsNeeded() || BufferIsLocal(buffer))
return PageGetLSN(page);
/* Make sure we've got a real buffer, and that we hold a pin on it. */