mirror of
https://github.com/postgres/postgres.git
synced 2025-07-21 16:02:15 +03:00
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.
This commit is contained in:
@ -7413,12 +7413,11 @@ heap_xlog_visible(XLogRecPtr lsn, XLogRecord *record)
|
|||||||
ResolveRecoveryConflictWithSnapshot(xlrec->cutoff_xid, xlrec->node);
|
ResolveRecoveryConflictWithSnapshot(xlrec->cutoff_xid, xlrec->node);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If heap block was backed up, restore it. This can only happen with
|
* If heap block was backed up, restore it. (This can only happen with
|
||||||
* checksums enabled.
|
* checksums or wal_log_hints enabled).
|
||||||
*/
|
*/
|
||||||
if (record->xl_info & XLR_BKP_BLOCK(1))
|
if (record->xl_info & XLR_BKP_BLOCK(1))
|
||||||
{
|
{
|
||||||
Assert(DataChecksumsEnabled());
|
|
||||||
(void) RestoreBackupBlock(lsn, record, 1, false, false);
|
(void) RestoreBackupBlock(lsn, record, 1, false, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -7441,11 +7440,11 @@ heap_xlog_visible(XLogRecPtr lsn, XLogRecord *record)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't bump the LSN of the heap page when setting the
|
* We don't bump the LSN of the heap page when setting the
|
||||||
* visibility map bit (unless checksums are enabled, in which case
|
* visibility map bit (unless checksums or wal_log_hints is
|
||||||
* we must), because that would generate an unworkable volume of
|
* enabled, in which case we must), because that would generate an
|
||||||
* full-page writes. This exposes us to torn page hazards, but
|
* unworkable volume of full-page writes. This exposes us to torn
|
||||||
* since we're not inspecting the existing page contents in any
|
* page hazards, but since we're not inspecting the existing page
|
||||||
* way, we don't care.
|
* contents in any way, we don't care.
|
||||||
*
|
*
|
||||||
* However, all operations that clear the visibility map bit *do*
|
* However, all operations that clear the visibility map bit *do*
|
||||||
* bump the LSN, and those operations will only be replayed if the
|
* bump the LSN, and those operations will only be replayed if the
|
||||||
|
@ -2125,7 +2125,7 @@ BufferGetLSNAtomic(Buffer buffer)
|
|||||||
/*
|
/*
|
||||||
* If we don't need locking for correctness, fastpath out.
|
* If we don't need locking for correctness, fastpath out.
|
||||||
*/
|
*/
|
||||||
if (!DataChecksumsEnabled() || BufferIsLocal(buffer))
|
if (!XLogHintBitIsNeeded() || BufferIsLocal(buffer))
|
||||||
return PageGetLSN(page);
|
return PageGetLSN(page);
|
||||||
|
|
||||||
/* Make sure we've got a real buffer, and that we hold a pin on it. */
|
/* Make sure we've got a real buffer, and that we hold a pin on it. */
|
||||||
|
Reference in New Issue
Block a user