aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2019-09-13 16:36:28 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2019-09-13 16:36:28 -0300
commit41f3d262693b1d735a3683104e334f1e9b48d7f4 (patch)
tree6809a0f5e8bf5e5c29f7eb0d195e3656cadcf710
parent82d0ae919ff8e7a9cb9283420a8834c9b9344128 (diff)
downloadpostgresql-41f3d262693b1d735a3683104e334f1e9b48d7f4.tar.gz
postgresql-41f3d262693b1d735a3683104e334f1e9b48d7f4.zip
logical decoding: process ASSIGNMENT during snapshot build
Most WAL records are ignored in early SnapBuild snapshot build phases. But it's critical to process some of them, so that later messages have the correct transaction state after the snapshot is completely built; in particular, XLOG_XACT_ASSIGNMENT messages are critical in order for sub-transactions to be correctly assigned to their parent transactions, or at least one assert misbehaves, as reported by Ildar Musin. Diagnosed-by: Masahiko Sawada Author: Masahiko Sawada Discussion: https://postgr.es/m/CAONYFtOv+Er1p3WAuwUsy1zsCFrSYvpHLhapC_fMD-zNaRWxYg@mail.gmail.com
-rw-r--r--src/backend/replication/logical/decode.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c
index e3b05657f8a..caa6edda18e 100644
--- a/src/backend/replication/logical/decode.c
+++ b/src/backend/replication/logical/decode.c
@@ -217,12 +217,15 @@ DecodeXactOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
uint8 info = XLogRecGetInfo(r) & XLOG_XACT_OPMASK;
/*
- * No point in doing anything yet, data could not be decoded anyway. It's
- * ok not to call ReorderBufferProcessXid() in that case, except in the
- * assignment case there'll not be any later records with the same xid;
- * and in the assignment case we'll not decode those xacts.
+ * If the snapshot isn't yet fully built, we cannot decode anything, so
+ * bail out.
+ *
+ * However, it's critical to process XLOG_XACT_ASSIGNMENT records even
+ * when the snapshot is being built: it is possible to get later records
+ * that require subxids to be properly assigned.
*/
- if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT)
+ if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT &&
+ info != XLOG_XACT_ASSIGNMENT)
return;
switch (info)