@@ -210,7 +210,6 @@ pglogical_receiver_main(Datum main_arg)
210
210
MtmReplicationMode mode ;
211
211
212
212
ByteBuffer buf ;
213
- XLogRecPtr originStartPos = 0 ;
214
213
RepOriginId originId ;
215
214
char * originName ;
216
215
/* Buffer for COPY data */
@@ -248,6 +247,7 @@ pglogical_receiver_main(Datum main_arg)
248
247
{
249
248
int count ;
250
249
ConnStatusType status ;
250
+ XLogRecPtr originStartPos = 0 ;
251
251
252
252
/*
253
253
* Determine when and how we should open replication slot.
@@ -272,7 +272,7 @@ pglogical_receiver_main(Datum main_arg)
272
272
}
273
273
274
274
query = createPQExpBuffer ();
275
- #if 1 /* Do we need to recretate slot ? */
275
+ #if 1 /* Do we need to recreate slot ? */
276
276
if (mode == REPLMODE_RECOVERED ) { /* recreate slot */
277
277
appendPQExpBuffer (query , "DROP_REPLICATION_SLOT \"%s\"" , slotName );
278
278
res = PQexec (conn , query -> data );
@@ -305,8 +305,9 @@ pglogical_receiver_main(Datum main_arg)
305
305
306
306
/* Start logical replication at specified position */
307
307
if (mode == REPLMODE_RECOVERED ) {
308
- originStartPos = 0 ;
309
- } else {
308
+ originStartPos = Mtm -> nodes [nodeId ].restartLsn ;
309
+ }
310
+ if (originStartPos == 0 ) {
310
311
StartTransactionCommand ();
311
312
originName = psprintf (MULTIMASTER_SLOT_PATTERN , nodeId );
312
313
originId = replorigin_by_name (originName , true);
@@ -485,25 +486,22 @@ pglogical_receiver_main(Datum main_arg)
485
486
if (rc > hdr_len )
486
487
{
487
488
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 ;
496
495
}
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
+ }
507
505
ByteBufferAppend (& buf , ")" , 1 );
508
506
pq_sendbyte (& spill_info , '(' );
509
507
pq_sendint (& spill_info , buf .used , 4 );
0 commit comments