On Tue, Oct 20, 2020 at 9:46 AM Peter Smith <smithpb2...@gmail.com> wrote: > > > ========== > Patch v10-0002, File: src/backend/replication/logical/reorderbuffer.c > ========== > > COMMENT > There are some parts of the code where in my v6 review I had a doubt > about the mutually exclusive treatment of the "streaming" flag and the > "rbtxn_prepared(txn)" state. >
I am not sure about the exact specifics here but we can always prepare a transaction that is streamed. I have to raise one more point in this regard. Why do we need stream_commit_prepared_cb, stream_rollback_prepared_cb callbacks? Do we need to do something separate in pgoutput or otherwise for these APIs? If not, can't we use a non-stream version of these APIs instead? There appears to be a use-case for stream_prepare_cb which is to apply the existing changes on subscriber and call prepare but I can't see usecase for the other two APIs. One minor comment: v10-0001-Support-2PC-txn-base 1. @@ -574,6 +655,11 @@ void ReorderBufferQueueMessage(ReorderBuffer *, TransactionId, Snapshot snapsho void ReorderBufferCommit(ReorderBuffer *, TransactionId, XLogRecPtr commit_lsn, XLogRecPtr end_lsn, TimestampTz commit_time, RepOriginId origin_id, XLogRecPtr origin_lsn); +void ReorderBufferFinishPrepared(ReorderBuffer *rb, TransactionId xid, + XLogRecPtr commit_lsn, XLogRecPtr end_lsn, + TimestampTz commit_time, + RepOriginId origin_id, XLogRecPtr origin_lsn, + char *gid, bool is_commit); void ReorderBufferAssignChild(ReorderBuffer *, TransactionId, TransactionId, XLogRecPtr commit_lsn); void ReorderBufferCommitChild(ReorderBuffer *, TransactionId, TransactionId, XLogRecPtr commit_lsn, XLogRecPtr end_lsn); @@ -597,6 +683,15 @@ void ReorderBufferXidSetCatalogChanges(ReorderBuffer *, TransactionId xid, XLog bool ReorderBufferXidHasCatalogChanges(ReorderBuffer *, TransactionId xid); bool ReorderBufferXidHasBaseSnapshot(ReorderBuffer *, TransactionId xid); +bool ReorderBufferPrepareNeedSkip(ReorderBuffer *rb, TransactionId xid, + const char *gid); +bool ReorderBufferTxnIsPrepared(ReorderBuffer *rb, TransactionId xid, + const char *gid); +void ReorderBufferPrepare(ReorderBuffer *rb, TransactionId xid, + XLogRecPtr commit_lsn, XLogRecPtr end_lsn, + TimestampTz commit_time, + RepOriginId origin_id, XLogRecPtr origin_lsn, + char *gid); ReorderBufferTXN *ReorderBufferGetOldestTXN(ReorderBuf I don't think these changes belong to this patch as the definition of these functions is not part of this patch. -- With Regards, Amit Kapila.