Skip to content

Commit 4f7dbf0

Browse files
committed
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
1 parent 6d50fd4 commit 4f7dbf0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/backend/replication/logical/decode.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,15 @@ DecodeXactOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
213213
uint8 info = XLogRecGetInfo(r) & XLOG_XACT_OPMASK;
214214

215215
/*
216-
* No point in doing anything yet, data could not be decoded anyway. It's
217-
* ok not to call ReorderBufferProcessXid() in that case, except in the
218-
* assignment case there'll not be any later records with the same xid;
219-
* and in the assignment case we'll not decode those xacts.
216+
* If the snapshot isn't yet fully built, we cannot decode anything, so
217+
* bail out.
218+
*
219+
* However, it's critical to process XLOG_XACT_ASSIGNMENT records even
220+
* when the snapshot is being built: it is possible to get later records
221+
* that require subxids to be properly assigned.
220222
*/
221-
if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT)
223+
if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT &&
224+
info != XLOG_XACT_ASSIGNMENT)
222225
return;
223226

224227
switch (info)

0 commit comments

Comments
 (0)