Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a6370fd

Browse files
committed
Ensure that XLOG_HEAP2_VISIBLE always targets an initialized page.
Andres Freund
1 parent e2c84bc commit a6370fd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/backend/commands/vacuumlazy.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,24 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
663663
/* empty pages are always all-visible */
664664
if (!PageIsAllVisible(page))
665665
{
666+
/*
667+
* It's possible that another backend has extended the heap,
668+
* initialized the page, and then failed to WAL-log the page
669+
* due to an ERROR. Since heap extension is not WAL-logged,
670+
* recovery might try to replay our record setting the
671+
* page all-visible and find that the page isn't initialized,
672+
* which will cause a PANIC. To prevent that, check whether
673+
* the page has been previously WAL-logged, and if not, do that
674+
* now.
675+
*
676+
* XXX: It would be nice to use a logging method supporting
677+
* standard buffers here since log_newpage_buffer() will write
678+
* the full block instead of omitting the hole.
679+
*/
680+
if (RelationNeedsWAL(onerel) &&
681+
PageGetLSN(page) == InvalidXLogRecPtr)
682+
log_newpage_buffer(buf);
683+
666684
PageSetAllVisible(page);
667685
MarkBufferDirty(buf);
668686
visibilitymap_set(onerel, blkno, buf, InvalidXLogRecPtr,

0 commit comments

Comments
 (0)