From 8cfac2a258c3ae84f3c1c636916421493259990a Mon Sep 17 00:00:00 2001 From: Matthias van de Meent Date: Mon, 13 May 2024 13:48:04 +0200 Subject: [PATCH] Fix logging of non-standard pages in RelationCopyStorageUsingBuffer If the data in the page is non-standard (e.g. the VM, FSM, or an access method that doesn't update PageHeader's fields as required) then we may fail to WAL-log the data on that page. When the server crashes after flushing the WAL record, but before flushing the file writes, this data may be permanently lost. Reported-By: Konstantin Knizhnik --- src/backend/storage/buffer/bufmgr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 327ddb7adc88..78bc8ddf3901 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -5211,9 +5211,13 @@ RelationCopyStorageUsingBuffer(RelFileLocator srclocator, memcpy(dstPage, srcPage, BLCKSZ); MarkBufferDirty(dstBuf); - /* WAL-log the copied page. */ + /* + * WAL-log the copied page. + * Note that we don't know about the type of data contained in the + * page, so we can't report that the buffer is a standard page. + */ if (use_wal) - log_newpage_buffer(dstBuf, true); + log_newpage_buffer(dstBuf, false); END_CRIT_SECTION();