Skip to content

Commit 8f5120b

Browse files
danolivokelvich
authored andcommitted
1. Set the SIGINT signal handler of receiver workers to die() routine.
2. Set the SIGHUP signal handler of receiver workers to standard PostgresSigHupHandler() routine. 3. Add log messages for Cancel and Shutdown of BgwPool. 4. Change soft exit (BgwPoolShutdown) to hard exit (BgwPoolCancel) at the case of postmaster death.
1 parent 9f39a23 commit 8f5120b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/bgwpool.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ BgwPoolMainLoop(BgwPool* poolDesc)
123123
MtmBackgroundWorker = true;
124124
MtmIsLogicalReceiver = true;
125125

126-
pqsignal(SIGINT, ApplyCancelHandler);
126+
pqsignal(SIGINT, die);
127127
pqsignal(SIGQUIT, BgwShutdownHandler);
128128
pqsignal(SIGTERM, BgwShutdownHandler);
129-
pqsignal(SIGHUP, ApplyCancelHandler);
129+
pqsignal(SIGHUP, PostgresSigHupHandler);
130130

131131
// XXX: probably we should add static variable that signalizes that
132132
// we are between pool->active += 1 and pool->active -= 1, so if
@@ -396,6 +396,8 @@ BgwPoolShutdown(BgwPool* poolDesc)
396396
continue;
397397
WaitForBackgroundWorkerShutdown(poolDesc->bgwhandles[i]);
398398
}
399+
elog(LOG, "Shutdown of the receiver workers pool. Pool name = %s",
400+
poolDesc->poolName);
399401
}
400402

401403
/*
@@ -429,4 +431,6 @@ BgwPoolCancel(BgwPool* poolDesc)
429431
poolDesc->pending = 0;
430432
poolDesc->producerBlocked = false;
431433
memset(poolDesc->bgwhandles, 0, MtmMaxWorkers * sizeof(BackgroundWorkerHandle *));
434+
elog(LOG, "Cancel of the receiver workers pool. Pool name = %s",
435+
poolDesc->poolName);
432436
}

src/pglogical_receiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ pglogical_receiver_main(Datum main_arg)
702702
/* Emergency bailout if postmaster has died */
703703
if (rc & WL_POSTMASTER_DEATH)
704704
{
705-
BgwPoolShutdown(&Mtm->pools[nodeId-1]);
705+
BgwPoolCancel(&Mtm->pools[nodeId-1]);
706706
proc_exit(1);
707707
}
708708

0 commit comments

Comments
 (0)