Reorganize logical replication worker disconnect code
Move the walrcv_disconnect() calls into the before_shmem_exit handler. This makes sure the call is always made even during exit by signal, it saves some duplicate code, and it makes the logic more similar to walreceiver.c. Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
This commit is contained in:
parent
2d460179ba
commit
6812330f1c
@ -614,7 +614,13 @@ logicalrep_launcher_onexit(int code, Datum arg)
|
|||||||
static void
|
static void
|
||||||
logicalrep_worker_onexit(int code, Datum arg)
|
logicalrep_worker_onexit(int code, Datum arg)
|
||||||
{
|
{
|
||||||
|
/* Disconnect gracefully from the remote side. */
|
||||||
|
if (wrconn)
|
||||||
|
walrcv_disconnect(wrconn);
|
||||||
|
|
||||||
logicalrep_worker_detach();
|
logicalrep_worker_detach();
|
||||||
|
|
||||||
|
ApplyLauncherWakeup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SIGTERM: set flag to exit at next convenient time */
|
/* SIGTERM: set flag to exit at next convenient time */
|
||||||
|
@ -140,7 +140,6 @@ finish_sync_worker(void)
|
|||||||
CommitTransactionCommand();
|
CommitTransactionCommand();
|
||||||
|
|
||||||
/* Stop gracefully */
|
/* Stop gracefully */
|
||||||
walrcv_disconnect(wrconn);
|
|
||||||
proc_exit(0);
|
proc_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1329,7 +1329,6 @@ reread_subscription(void)
|
|||||||
"stop because the subscription was removed",
|
"stop because the subscription was removed",
|
||||||
MySubscription->name)));
|
MySubscription->name)));
|
||||||
|
|
||||||
walrcv_disconnect(wrconn);
|
|
||||||
proc_exit(0);
|
proc_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1344,7 +1343,6 @@ reread_subscription(void)
|
|||||||
"stop because the subscription was disabled",
|
"stop because the subscription was disabled",
|
||||||
MySubscription->name)));
|
MySubscription->name)));
|
||||||
|
|
||||||
walrcv_disconnect(wrconn);
|
|
||||||
proc_exit(0);
|
proc_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1359,7 +1357,6 @@ reread_subscription(void)
|
|||||||
"restart because the connection information was changed",
|
"restart because the connection information was changed",
|
||||||
MySubscription->name)));
|
MySubscription->name)));
|
||||||
|
|
||||||
walrcv_disconnect(wrconn);
|
|
||||||
proc_exit(0);
|
proc_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1374,7 +1371,6 @@ reread_subscription(void)
|
|||||||
"restart because subscription was renamed",
|
"restart because subscription was renamed",
|
||||||
MySubscription->name)));
|
MySubscription->name)));
|
||||||
|
|
||||||
walrcv_disconnect(wrconn);
|
|
||||||
proc_exit(0);
|
proc_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1392,7 +1388,6 @@ reread_subscription(void)
|
|||||||
"restart because the replication slot name was changed",
|
"restart because the replication slot name was changed",
|
||||||
MySubscription->name)));
|
MySubscription->name)));
|
||||||
|
|
||||||
walrcv_disconnect(wrconn);
|
|
||||||
proc_exit(0);
|
proc_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1407,7 +1402,6 @@ reread_subscription(void)
|
|||||||
"restart because subscription's publications were changed",
|
"restart because subscription's publications were changed",
|
||||||
MySubscription->name)));
|
MySubscription->name)));
|
||||||
|
|
||||||
walrcv_disconnect(wrconn);
|
|
||||||
proc_exit(0);
|
proc_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1610,8 +1604,6 @@ ApplyWorkerMain(Datum main_arg)
|
|||||||
/* Run the main loop. */
|
/* Run the main loop. */
|
||||||
LogicalRepApplyLoop(origin_startpos);
|
LogicalRepApplyLoop(origin_startpos);
|
||||||
|
|
||||||
walrcv_disconnect(wrconn);
|
|
||||||
|
|
||||||
/* We should only get here if we received SIGTERM */
|
/* We should only get here if we received SIGTERM */
|
||||||
proc_exit(0);
|
proc_exit(0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user