Skip to content

Commit 0887949

Browse files
hlinnakatristan957
authored andcommitted
Fix errors in WAL redo about relpersistence mismatch.
In the WAL redo process, even "permanent" buffers are stored in the local buffer cache. Need to pass RELPERSISTENCE_PERMANENT to smgropen() in that case.
1 parent f889dfb commit 0887949

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/storage/buffer/localbuf.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "access/parallel.h"
1919
#include "catalog/catalog.h"
2020
#include "executor/instrument.h"
21+
#include "miscadmin.h"
2122
#include "storage/buf_internals.h"
2223
#include "storage/bufmgr.h"
2324
#include "utils/guc.h"
@@ -215,7 +216,10 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum, BlockNumber blockNum,
215216
Page localpage = (char *) LocalBufHdrGetBlock(bufHdr);
216217

217218
/* Find smgr relation for buffer */
218-
oreln = smgropen(bufHdr->tag.rnode, MyBackendId, RELPERSISTENCE_TEMP);
219+
if (am_wal_redo_postgres && MyBackendId == InvalidBackendId)
220+
oreln = smgropen(bufHdr->tag.rnode, MyBackendId, RELPERSISTENCE_PERMANENT);
221+
else
222+
oreln = smgropen(bufHdr->tag.rnode, MyBackendId, RELPERSISTENCE_TEMP);
219223

220224
PageSetChecksumInplace(localpage, bufHdr->tag.blockNum);
221225

0 commit comments

Comments
 (0)