aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlogutils.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2012-09-14 09:35:07 -0400
committerRobert Haas <rhaas@postgresql.org>2012-09-14 09:39:10 -0400
commitfef2c17807e095a04441e4f1fe05f75d5578ead2 (patch)
tree8a1a92ca03183fdbe80bc34c5ee3517a5950e903 /src/backend/access/transam/xlogutils.c
parentdf4234d7a9a522073712138da422836e5a637671 (diff)
downloadpostgresql-fef2c17807e095a04441e4f1fe05f75d5578ead2.tar.gz
postgresql-fef2c17807e095a04441e4f1fe05f75d5578ead2.zip
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.
Diffstat (limited to 'src/backend/access/transam/xlogutils.c')
-rw-r--r--src/backend/access/transam/xlogutils.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c
index cbb61bb899d..0932e600a77 100644
--- a/src/backend/access/transam/xlogutils.c
+++ b/src/backend/access/transam/xlogutils.c
@@ -371,6 +371,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;
@@ -380,6 +382,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);