logical decoding: Tell reorderbuffer about all xids.
authorAndres Freund <[email protected]>
Sun, 6 Mar 2016 02:02:20 +0000 (18:02 -0800)
committerAndres Freund <[email protected]>
Sun, 6 Mar 2016 02:02:20 +0000 (18:02 -0800)
commit6e759cefe809cb7852cdf6ea3088d8604a817185
tree7dcf16ff378869be6cfa092f488a5804ed31a449
parentf95f1ce003d1453d78a8dd05577d6c61b251d48d
logical decoding: Tell reorderbuffer about all xids.

Logical decoding's reorderbuffer keeps transactions in an LSN ordered
list for efficiency. To make that's efficiently possible upper-level
xids are forced to be logged before nested subtransaction xids.  That
only works though if these records are all looked at: Unfortunately we
didn't do so for e.g. row level locks, which are otherwise uninteresting
for logical decoding.

This could lead to errors like:
"ERROR: subxact logged without previous toplevel record".

It's not sufficient to just look at row locking records, the xid could
appear first due to a lot of other types of records (which will trigger
the transaction to be marked logged with MarkCurrentTransactionIdLoggedIfAny).
So invent infrastructure to tell reorderbuffer about xids seen, when
they'd otherwise not pass through reorderbuffer.c.

Reported-By: Jarred Ward
Bug: #13844
Discussion: 20160105033249[email protected]
Backpatch: 9.4, where logical decoding was added
contrib/test_decoding/Makefile
contrib/test_decoding/expected/xact.out [new file with mode: 0644]
contrib/test_decoding/sql/xact.sql [new file with mode: 0644]
src/backend/replication/logical/decode.c
src/backend/replication/logical/reorderbuffer.c
src/backend/replication/logical/snapbuild.c
src/include/replication/reorderbuffer.h