@@ -210,7 +210,6 @@ pglogical_receiver_main(Datum main_arg)
210210 MtmReplicationMode mode ;
211211
212212 ByteBuffer buf ;
213- XLogRecPtr originStartPos = 0 ;
214213 RepOriginId originId ;
215214 char * originName ;
216215 /* Buffer for COPY data */
@@ -248,6 +247,7 @@ pglogical_receiver_main(Datum main_arg)
248247 {
249248 int count ;
250249 ConnStatusType status ;
250+ XLogRecPtr originStartPos = 0 ;
251251
252252 /*
253253 * Determine when and how we should open replication slot.
@@ -272,7 +272,7 @@ pglogical_receiver_main(Datum main_arg)
272272 }
273273
274274 query = createPQExpBuffer ();
275- #if 1 /* Do we need to recretate slot ? */
275+ #if 1 /* Do we need to recreate slot ? */
276276 if (mode == REPLMODE_RECOVERED ) { /* recreate slot */
277277 appendPQExpBuffer (query , "DROP_REPLICATION_SLOT \"%s\"" , slotName );
278278 res = PQexec (conn , query -> data );
@@ -305,8 +305,9 @@ pglogical_receiver_main(Datum main_arg)
305305
306306 /* Start logical replication at specified position */
307307 if (mode == REPLMODE_RECOVERED ) {
308- originStartPos = 0 ;
309- } else {
308+ originStartPos = Mtm -> nodes [nodeId ].restartLsn ;
309+ }
310+ if (originStartPos == 0 ) {
310311 StartTransactionCommand ();
311312 originName = psprintf (MULTIMASTER_SLOT_PATTERN , nodeId );
312313 originId = replorigin_by_name (originName , true);
@@ -485,25 +486,22 @@ pglogical_receiver_main(Datum main_arg)
485486 if (rc > hdr_len )
486487 {
487488 stmt = copybuf + hdr_len ;
488-
489- if (buf .used >= MtmTransSpillThreshold * MB ) {
490- if (spill_file < 0 ) {
491- int file_id ;
492- spill_file = MtmCreateSpillFile (nodeId , & file_id );
493- pq_sendbyte (& spill_info , 'F' );
494- pq_sendint (& spill_info , nodeId , 4 );
495- pq_sendint (& spill_info , file_id , 4 );
489+ if (mode == REPLMODE_RECOVERED ) {
490+ if (stmt [0 ] != 'B' ) {
491+ output_written_lsn = Max (walEnd , output_written_lsn );
492+ continue ;
493+ }
494+ mode = REPLMODE_NORMAL ;
496495 }
497- ByteBufferAppend (& buf , ")" , 1 );
498- pq_sendbyte (& spill_info , '(' );
499- pq_sendint (& spill_info , buf .used , 4 );
500- MtmSpillToFile (spill_file , buf .data , buf .used );
501- ByteBufferReset (& buf );
502- }
503- ByteBufferAppend (& buf , stmt , rc - hdr_len );
504- if (stmt [0 ] == 'C' ) /* commit|prepare */
505- {
506- if (spill_file >= 0 ) {
496+
497+ if (buf .used >= MtmTransSpillThreshold * MB ) {
498+ if (spill_file < 0 ) {
499+ int file_id ;
500+ spill_file = MtmCreateSpillFile (nodeId , & file_id );
501+ pq_sendbyte (& spill_info , 'F' );
502+ pq_sendint (& spill_info , nodeId , 4 );
503+ pq_sendint (& spill_info , file_id , 4 );
504+ }
507505 ByteBufferAppend (& buf , ")" , 1 );
508506 pq_sendbyte (& spill_info , '(' );
509507 pq_sendint (& spill_info , buf .used , 4 );
0 commit comments