>From 07d0f4330f7c25bcec9e356527b0dc86372d2886 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Thu, 15 May 2014 22:23:12 +0200 Subject: [PATCH 1/2] Initialize all members of xl_xact_commit during prepared transaction commits. Commit dd428c79 added dbId and tsId to the xl_xact_commit struct but missed that prepared transaction commits reuse that struct. Fix that. Because those fields were used WAL logged unitialized a hot standby node could miss relcache init file invalidations leading to errors like ERROR: could not open file "...": No such file or directory on the standby. A restart of the database is sufficient to fix the problem. As problems can only be triggered when a system table/index has been rewritten in a transaction using two phase commit the problem is unlikely to have affected many installations. Found while investigating a logical decoding bugreport from Heikki. Backpatch to 9.0 where the bug was introduced. --- src/backend/access/transam/twophase.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 2cefa08..d5409a6 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -2082,9 +2082,13 @@ RecordTransactionCommitPrepared(TransactionId xid, /* Emit the XLOG commit record */ xlrec.xid = xid; - xlrec.crec.xact_time = GetCurrentTimestamp(); + xlrec.crec.xinfo = initfileinval ? XACT_COMPLETION_UPDATE_RELCACHE_FILE : 0; - xlrec.crec.nmsgs = 0; + + xlrec.crec.dbId = MyDatabaseId; + xlrec.crec.tsId = MyDatabaseTableSpace; + + xlrec.crec.xact_time = GetCurrentTimestamp(); xlrec.crec.nrels = nrels; xlrec.crec.nsubxacts = nchildren; xlrec.crec.nmsgs = ninvalmsgs; -- 2.0.0.rc2.4.g1dc51c6.dirty