8000 Fix theoretical torn page hazard. · postgres/postgres@5eaf3e3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5eaf3e3

Browse files
committed
Fix theoretical torn page hazard.
The original report was concerned with a possible inconsistency between the heap and the visibility map, which I was unable to confirm. The concern has been retracted. However, there did seem to be a torn page hazard when using checksums. By not setting the heap page LSN during redo, the protections of minRecoveryPoint were bypassed. Fixed, along with a misleading comment. It may have been impossible to hit this problem in practice, because it would require a page tear between the checksum and the flags, so I am marking this as a theoretical risk. But, as discussed, it did violate expectations about the page LSN, so it may have other consequences. Backpatch to all supported versions. Reported-by: Konstantin Knizhnik Reviewed-by: Konstantin Knizhnik Discussion: https://postgr.es/m/fed17dac-8cb8-4f5b-d462-1bb4908c029e@garret.ru Backpatch-through: 11
1 parent 421f336 commit 5eaf3e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/backend/access/heap/heapam.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8437,8 +8437,7 @@ heap_xlog_visible(XLogReaderState *record)
84378437
/*
84388438
* We don't bump the LSN of the heap page when setting the visibility
84398439
* map bit (unless checksums or wal_hint_bits is enabled, in which
8440-
* case we must), because that would generate an unworkable volume of
8441-
* full-page writes. This exposes us to torn page hazards, but since
8440+
* case we must). This exposes us to torn page hazards, but since
84428441
* we're not inspecting the existing page contents in any way, we
84438442
* don't care.
84448443
*
@@ -8452,6 +8451,9 @@ heap_xlog_visible(XLogReaderState *record)
84528451

84538452
PageSetAllVisible(page);
84548453

8454+
if (XLogHintBitIsNeeded())
8455+
PageSetLSN(page, lsn);
8456+
84558457
MarkBufferDirty(buffer);
84568458
}
84578459
else if (action == BLK_RESTORED)

0 commit comments

Comments
 (0)
0