From 371d91bb3c332e5c58608876a7847d2c2ff38ed9 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 79ca9d18d07b..05899596776e 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -4695,9 +4695,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();