Content-Length: 304936 | pFad | http://github.com/postgrespro/postgres/commit/beb850e1d873f8920a78b9b9ee27e9f87c95592f

CE Properly set relpersistence for fake relcache entries. · postgrespro/postgres@beb850e · GitHub
Skip to content

Commit beb850e

Browse files
committed
Properly set relpersistence for fake relcache entries.
This can result in buffers failing to be properly flushed at checkpoint time, leading to data loss. Report, diagnosis, and patch by Jeff Davis.
1 parent 9afc648 commit beb850e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/backend/access/transam/xlogutils.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ CreateFakeRelcacheEntry(RelFileNode rnode)
394394
FakeRelCacheEntry fakeentry;
395395
Relation rel;
396396

397+
Assert(InRecovery);
398+
397399
/* Allocate the Relation struct and all related space in one block. */
398400
fakeentry = palloc0(sizeof(FakeRelCacheEntryData));
399401
rel = (Relation) fakeentry;
@@ -403,6 +405,9 @@ CreateFakeRelcacheEntry(RelFileNode rnode)
403405
/* We will never be working with temp rels during recovery */
404406
rel->rd_backend = InvalidBackendId;
405407

408+
/* It must be a permanent table if we're in recovery. */
409+
rel->rd_rel->relpersistence = RELPERSISTENCE_PERMANENT;
410+
406411
/* We don't know the name of the relation; use relfilenode instead */
407412
sprintf(RelationGetRelationName(rel), "%u", rnode.relNode);
408413

src/backend/storage/buffer/bufmgr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ ReadBufferWithoutRelcache(RelFileNode rnode, ForkNumber forkNum,
271271

272272
SMgrRelation smgr = smgropen(rnode, InvalidBackendId);
273273

274+
Assert(InRecovery);
275+
274276
return ReadBuffer_common(smgr, RELPERSISTENCE_PERMANENT, forkNum, blockNum,
275277
mode, strategy, &hit);
276278
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/beb850e1d873f8920a78b9b9ee27e9f87c95592f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy