@@ -194,7 +194,7 @@ static char const* const MtmReplicationModeName[] =
194194{
195195"recovered" ,/* SLOT_CREATE_NEW: recovery of node is completed so drop old slot and restart replication from the current position in WAL */
196196"recovery" ,/* SLOT_OPEN_EXISTED: perform recorvery of the node by applying all data from theslot from specified point */
197- "normal" /* SLOT_OPEN_ALWAYS: normal mode: useexisteed slot or create new one and start receiving data from it from the specified position */
197+ "normal" /* SLOT_OPEN_ALWAYS: normal mode: useexisted slot or create new one and start receiving data from it from the specified position */
198198};
199199
200200static void
@@ -248,6 +248,7 @@ pglogical_receiver_main(Datum main_arg)
248248PQfinish (conn );
249249ereport (WARNING , (errmsg ("%s: Could not establish connection to remote server" ,
250250worker_proc )));
251+ /* Do not make decision about node status here because at startup peer node may just no yet started */
251252/* MtmOnNodeDisconnect(nodeId); */
252253proc_exit (1 );
253254}
@@ -271,6 +272,7 @@ pglogical_receiver_main(Datum main_arg)
271272PQclear (res );
272273ereport (ERROR , (errmsg ("%s: Could not create logical slot" ,
273274worker_proc )));
275+ MtmOnNodeDisconnect (nodeId );
274276proc_exit (1 );
275277}
276278}
@@ -312,6 +314,7 @@ pglogical_receiver_main(Datum main_arg)
312314PQclear (res );
313315ereport (WARNING , (errmsg ("%s: Could not start logical replication" ,
314316worker_proc )));
317+ MtmOnNodeDisconnect (nodeId );
315318proc_exit (1 );
316319}
317320PQclear (res );
@@ -402,6 +405,7 @@ pglogical_receiver_main(Datum main_arg)
402405{
403406ereport (LOG , (errmsg ("%s: streaming header too small: %d" ,
404407worker_proc ,rc )));
408+ MtmOnNodeDisconnect (nodeId );
405409proc_exit (1 );
406410}
407411replyRequested = copybuf [pos ];
@@ -421,15 +425,18 @@ pglogical_receiver_main(Datum main_arg)
421425int64 now = feGetCurrentTimestamp ();
422426
423427/* Leave is feedback is not sent properly */
424- if (!sendFeedback (conn ,now ,nodeId ))
428+ if (!sendFeedback (conn ,now ,nodeId )) {
429+ MtmOnNodeDisconnect (nodeId );
425430proc_exit (1 );
431+ }
426432}
427433continue ;
428434}
429435else if (copybuf [0 ]!= 'w' )
430436{
431437ereport (LOG , (errmsg ("%s: Incorrect streaming header" ,
432438worker_proc )));
439+ MtmOnNodeDisconnect (nodeId );
433440proc_exit (1 );
434441}
435442
@@ -538,6 +545,7 @@ pglogical_receiver_main(Datum main_arg)
538545{
539546ereport (LOG , (errmsg ("%s: Incorrect status received... Leaving." ,
540547worker_proc )));
548+ MtmOnNodeDisconnect (nodeId );
541549proc_exit (1 );
542550}
543551
@@ -546,6 +554,7 @@ pglogical_receiver_main(Datum main_arg)
546554{
547555ereport (LOG , (errmsg ("%s: Data remaining on the socket... Leaving." ,
548556worker_proc )));
557+ MtmOnNodeDisconnect (nodeId );
549558proc_exit (1 );
550559}
551560continue ;
@@ -564,6 +573,7 @@ pglogical_receiver_main(Datum main_arg)
564573{
565574ereport (LOG , (errmsg ("%s: Failure while receiving changes..." ,
566575worker_proc )));
576+ MtmOnNodeDisconnect (nodeId );
567577proc_exit (1 );
568578}
569579}