Skip to content

Commit e8c7f40

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 ca08ea5 commit e8c7f40

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
@@ -202,12 +202,15 @@ DecodeXactOp(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
202202
uint8 info = r->xl_info & ~XLR_INFO_MASK;
203203

204204
/*
205-
* No point in doing anything yet, data could not be decoded anyway. It's
206-
* ok not to call ReorderBufferProcessXid() in that case, except in the
207-
* assignment case there'll not be any later records with the same xid;
208-
* and in the assignment case we'll not decode those xacts.
205+
* If the snapshot isn't yet fully built, we cannot decode anything, so
206+
* bail out.
207+
*
208+
* However, it's critical to process XLOG_XACT_ASSIGNMENT records even
209+
* when the snapshot is being built: it is possible to get later records
210+
* that require subxids to be properly assigned.
209211
*/
210-
if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT)
212+
if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT &&
213+
info != XLOG_XACT_ASSIGNMENT)
211214
return;
212215

213216
switch (info)

0 commit comments

Comments
 (0)