@@ -59,7 +59,7 @@ typedef struct TupleData
5959 bool changed [MaxTupleAttributeNumber ];
6060} TupleData ;
6161
62- static int MtmTransactionRecords ;
62+ static bool inside_tx = false ;
6363
6464static Relation read_rel (StringInfo s , LOCKMODE mode );
6565static void read_tuple_parts (StringInfo s , Relation rel , TupleData * tup );
@@ -528,6 +528,8 @@ MtmEndSession(void)
528528 if (replorigin_session_origin != InvalidRepOriginId ) {
529529 MTM_LOG2 ("%d: Begin reset replorigin session for node %d: %d, progress %lx" , MyProcPid , MtmReplicationNodeId , replorigin_session_origin , replorigin_session_get_progress (false));
530530 replorigin_session_origin = InvalidRepOriginId ;
531+ replorigin_session_origin_lsn = InvalidXLogRecPtr ;
532+ replorigin_session_origin_timestamp = 0 ;
531533 replorigin_session_reset ();
532534 if (unlock ) {
533535 MtmUnlockNode (MtmReplicationNodeId );
@@ -539,42 +541,25 @@ MtmEndSession(void)
539541static void
540542process_remote_commit (StringInfo in )
541543{
542- int i ;
543544 uint8 flags ;
544545 csn_t csn ;
545546 const char * gid = NULL ;
546547 XLogRecPtr end_lsn ;
547548 XLogRecPtr origin_lsn ;
548- RepOriginId originId ;
549- int n_records ;
549+ int origin_node ;
550550 /* read flags */
551551 flags = pq_getmsgbyte (in );
552552 MtmReplicationNodeId = pq_getmsgbyte (in );
553553
554- n_records = pq_getmsgint (in , 4 );
555- if (MtmTransactionRecords != n_records ) {
556- elog (ERROR , "Transaction %d flags %d contains %d records instead of %d" , MtmGetCurrentTransactionId (), flags , MtmTransactionRecords , n_records );
557- }
558-
559554 /* read fields */
560555 replorigin_session_origin_lsn = pq_getmsgint64 (in ); /* commit_lsn */
561556 end_lsn = pq_getmsgint64 (in ); /* end_lsn */
562557 replorigin_session_origin_timestamp = pq_getmsgint64 (in ); /* commit_time */
563558
564- originId = ( RepOriginId ) pq_getmsgint ( in , 2 );
559+ origin_node = pq_getmsgbyte ( in );
565560 origin_lsn = pq_getmsgint64 (in );
561+ Mtm -> nodes [origin_node - 1 ].restartLsn = origin_lsn ;
566562
567- if (originId != InvalidRepOriginId ) {
568- for (i = 0 ; i < Mtm -> nAllNodes ; i ++ ) {
569- if (Mtm -> nodes [i ].originId == originId ) {
570- Mtm -> nodes [i ].restartLsn = origin_lsn ;
571- break ;
572- }
573- }
574- if (i == Mtm -> nAllNodes ) {
575- elog (WARNING , "Failed to map origin %d" , originId );
576- }
577- }
578563 Assert (replorigin_session_origin == InvalidRepOriginId );
579564
580565 switch (PGLOGICAL_XACT_EVENT (flags ))
@@ -676,8 +661,6 @@ process_remote_insert(StringInfo s, Relation rel)
676661 ScanKey * index_keys ;
677662 int i ;
678663
679- MtmTransactionRecords += 1 ;
680-
681664 estate = create_rel_estate (rel );
682665 newslot = ExecInitExtraTupleSlot (estate );
683666 oldslot = ExecInitExtraTupleSlot (estate );
@@ -776,8 +759,6 @@ process_remote_update(StringInfo s, Relation rel)
776759 ScanKeyData skey [INDEX_MAX_KEYS ];
777760 HeapTuple remote_tuple = NULL ;
778761
779- MtmTransactionRecords += 1 ;
780-
781762 action = pq_getmsgbyte (s );
782763
783764 /* old key present, identifying key changed */
@@ -895,8 +876,6 @@ process_remote_delete(StringInfo s, Relation rel)
895876 ScanKeyData skey [INDEX_MAX_KEYS ];
896877 bool found_old ;
897878
898- MtmTransactionRecords += 1 ;
899-
900879 estate = create_rel_estate (rel );
901880 oldslot = ExecInitExtraTupleSlot (estate );
902881 ExecSetSlotDescriptor (oldslot , RelationGetDescr (rel ));
@@ -984,7 +963,6 @@ void MtmExecutor(int id, void* work, size_t size)
984963 }
985964 MemoryContextSwitchTo (ApplyContext );
986965 replorigin_session_origin = InvalidRepOriginId ;
987- MtmTransactionRecords = 0 ;
988966 PG_TRY ();
989967 {
990968 while (true) {
0 commit comments