On Fri, Oct 16, 2020 at 5:21 PM Peter Smith <smithpb2...@gmail.com> wrote: > > Hello Ajin, > > The v9 patches provided support for two-phase transactions for NON-streaming. > > Now I have added STREAM support for two-phase transactions, and bumped > all patches to version v10. > > (The 0001 and 0002 patches are unchanged. Only 0003 is changed). > > -- > > There are a few TODO/FIXME comments in the code highlighting parts > needing some attention. > > There is a #define DEBUG_STREAM_2PC useful for debugging, which I can > remove later. > > All the patches have some whitespaces issues when applied. We can > resolve them as we go. > > Please let me know any comments/feedback.
Hi Peter, Thanks for your patch. Some comments for your patch: Comments: src/backend/replication/logical/worker.c @@ -888,6 +888,319 @@ apply_handle_prepare(StringInfo s) + /* + * FIXME - Following condition was in apply_handle_prepare_txn except I found it was ALWAYS IsTransactionState() == false + * The synchronization worker runs in single transaction. * + if (IsTransactionState() && !am_tablesync_worker()) + */ + if (!am_tablesync_worker()) Comment: I dont think a tablesync worker will use streaming, none of the other stream APIs check this, this might not be relevant for stream_prepare either. + /* + * ================================================================================================== + * The following chunk of code is largely cut/paste from the existing apply_handle_prepare_commit_txn Comment: Here, I think you meant apply_handle_stream_commit. Also rather than duplicating this chunk of code, you could put it in a new function. + /* open the spool file for the committed transaction */ + changes_filename(path, MyLogicalRepWorker->subid, xid); Comment: Here the comment should read "committed/prepared" rather than "committed" + else + { + /* Process any invalidation messages that might have accumulated. */ + AcceptInvalidationMessages(); + maybe_reread_subscription(); + } Comment: This else block might not be necessary as a tablesync worker will not initiate the streaming APIs. + BeginTransactionBlock(); + CommitTransactionCommand(); + StartTransactionCommand(); Comment: Rereading the code and the transaction state description in src/backend/access/transam/README. I am not entirely sure if the BeginTransactionBlock followed by CommitTransactionBlock is really needed here. I understand this code was copied over from apply_handle_prepare_txn, but now looking back I'm not so sure if it is correct. The transaction would have already begin as part of applying the changes, why begin it again? Maybe Amit could confirm this. END regards, Ajin Cherian Fujitsu Australia