summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-05-16 09:47:50 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-05-16 10:06:03 +0300
commit39b3739c05688b5cd5d5da8c52fa5476304eff11 (patch)
tree1830863b98c290b64b44d1addce6fa3839b63d3b
parentda05e57f70d42a41a0c6f01e2440bd3efbd972d1 (diff)
Initialize tsId and dbId fields in WAL record of COMMIT PREPARED.
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 left unitialized, replaying a commit prepared WAL record in a hot standby node would fail to remove the relcache init file. That can lead to "could not open file" errors on the standby. Relcache init file only needs to be removed when a system table/index is rewritten in the transaction using two phase commit, so that should be rare in practice. In HEAD, the incorrect dbId/tsId values are also used for filtering in logical replication code, causing the transaction to always be filtered out. Analysis and fix by Andres Freund. Backpatch to 9.0 where hot standby was introduced.
-rw-r--r--src/backend/access/transam/twophase.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 3044c4f958c..cf0a6c40625 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -2055,9 +2055,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;