From beb850e1d873f8920a78b9b9ee27e9f87c95592f Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 14 Sep 2012 09:35:07 -0400 Subject: 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. --- src/backend/access/transam/xlogutils.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/backend/access/transam/xlogutils.c') diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c index 6ddcc59b37a..5676120a863 100644 --- a/src/backend/access/transam/xlogutils.c +++ b/src/backend/access/transam/xlogutils.c @@ -394,6 +394,8 @@ CreateFakeRelcacheEntry(RelFileNode rnode) FakeRelCacheEntry fakeentry; Relation rel; + Assert(InRecovery); + /* Allocate the Relation struct and all related space in one block. */ fakeentry = palloc0(sizeof(FakeRelCacheEntryData)); rel = (Relation) fakeentry; @@ -403,6 +405,9 @@ CreateFakeRelcacheEntry(RelFileNode rnode) /* We will never be working with temp rels during recovery */ rel->rd_backend = InvalidBackendId; + /* It must be a permanent table if we're in recovery. */ + rel->rd_rel->relpersistence = RELPERSISTENCE_PERMANENT; + /* We don't know the name of the relation; use relfilenode instead */ sprintf(RelationGetRelationName(rel), "%u", rnode.relNode); -- cgit v1.2.3