(unnamed)
text/plain
Filename: (unnamed)
Type: text/plain
Part: 0
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 46e66608cf..503116764f 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -887,9 +887,14 @@ AssertTXNLsnOrder(ReorderBuffer *rb)
if (cur_txn->end_lsn != InvalidXLogRecPtr)
Assert(cur_txn->first_lsn <= cur_txn->end_lsn);
- /* Current initial LSN must be strictly higher than previous */
+ /*
+ * Current initial LSN must be strictly higher than previous. except
+ * this transaction is created by XLOG_RUNNING_XACTS. If one
+ * XLOG_RUNNING_XACTS creates multiple transactions, they share the
+ * same LSN. See SnapBuildProcessRunningXacts.
+ */
if (prev_first_lsn != InvalidXLogRecPtr)
- Assert(prev_first_lsn < cur_txn->first_lsn);
+ Assert(prev_first_lsn <= cur_txn->first_lsn);
/* known-as-subtxn txns must not be listed */
Assert(!rbtxn_is_known_subxact(cur_txn));
diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index a5333349a8..58859112dc 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -1097,6 +1097,20 @@ SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, xl_running_xact
*/
if (builder->state < SNAPBUILD_CONSISTENT)
{
+ /*
+ * At the time we passed the first XLOG_RUNNING_XACTS record, the
+ * transactions notified by the record may have updated
+ * catalogs. Register the transactions with marking them as having
+ * caused catalog changes. The worst misbehavior here is some spurious
+ * invalidation at decoding start.
+ */
+ if (builder->state == SNAPBUILD_START)
+ {
+ for (int i = 0 ; i < running->xcnt + running->subxcnt ; i++)
+ ReorderBufferXidSetCatalogChanges(builder->reorder,
+ running->xids[i], lsn);
+ }
+
/* returns false if there's no point in performing cleanup just yet */
if (!SnapBuildFindSnapshot(builder, lsn, running))
return;