Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5c83915

Browse files
committed
reload config on sighup in bgworkers
1 parent 9a51ff8 commit 5c83915

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

arbiter.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ static void MtmSender(Datum arg)
715715
pqsignal(SIGINT, SetStop);
716716
pqsignal(SIGQUIT, SetStop);
717717
pqsignal(SIGTERM, SetStop);
718+
pqsignal(SIGHUP, PostgresSigHupHandler);
718719

719720
/* We're now ready to receive signals */
720721
BackgroundWorkerUnblockSignals();
@@ -733,6 +734,12 @@ static void MtmSender(Datum arg)
733734
PGSemaphoreLock(&Mtm->sendSemaphore);
734735
CHECK_FOR_INTERRUPTS();
735736

737+
if (ConfigReloadPending)
738+
{
739+
ConfigReloadPending = false;
740+
ProcessConfigFile(PGC_SIGHUP);
741+
}
742+
736743
MtmCheckHeartbeat();
737744
/*
738745
* Use shared lock to improve locality,
@@ -794,6 +801,7 @@ static void MtmMonitor(Datum arg)
794801
pqsignal(SIGINT, SetStop);
795802
pqsignal(SIGQUIT, SetStop);
796803
pqsignal(SIGTERM, SetStop);
804+
pqsignal(SIGHUP, PostgresSigHupHandler);
797805

798806
MtmBackgroundWorker = true;
799807

@@ -808,6 +816,13 @@ static void MtmMonitor(Datum arg)
808816
if (rc & WL_POSTMASTER_DEATH) {
809817
break;
810818
}
819+
820+
if (ConfigReloadPending)
821+
{
822+
ConfigReloadPending = false;
823+
ProcessConfigFile(PGC_SIGHUP);
824+
}
825+
811826
MtmRefreshClusterStatus();
812827
}
813828
}
@@ -833,6 +848,7 @@ static void MtmReceiver(Datum arg)
833848
pqsignal(SIGINT, SetStop);
834849
pqsignal(SIGQUIT, SetStop);
835850
pqsignal(SIGTERM, SetStop);
851+
pqsignal(SIGHUP, PostgresSigHupHandler);
836852

837853
MtmBackgroundWorker = true;
838854

@@ -868,7 +884,14 @@ static void MtmReceiver(Datum arg)
868884
for (j = 0; j < n; j++) {
869885
if (events[j].events & EPOLLIN)
870886
#else
871-
fd_set events;
887+
fd_set events;
888+
889+
if (ConfigReloadPending)
890+
{
891+
ConfigReloadPending = false;
892+
ProcessConfigFile(PGC_SIGHUP);
893+
}
894+
872895
do {
873896
struct timeval tv;
874897
events = inset;

bgwpool.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "bgwpool.h"
1616
#include "multimaster.h"
17+
#include "utils/guc.h"
1718

1819
bool MtmIsLogicalReceiver;
1920
int MtmMaxWorkers;
@@ -43,14 +44,21 @@ static void BgwPoolMainLoop(BgwPool* pool)
4344
pqsignal(SIGINT, BgwShutdownWorker);
4445
pqsignal(SIGQUIT, BgwShutdownWorker);
4546
pqsignal(SIGTERM, BgwShutdownWorker);
47+
pqsignal(SIGHUP, PostgresSigHupHandler);
4648

4749
BackgroundWorkerUnblockSignals();
4850
BackgroundWorkerInitializeConnection(pool->dbname, pool->dbuser);
4951
ActivePortal = &fakePortal;
5052
ActivePortal->status = PORTAL_ACTIVE;
5153
ActivePortal->sourceText = "";
5254

53-
while (true) {
55+
while (true) {
56+
if (ConfigReloadPending)
57+
{
58+
ConfigReloadPending = false;
59+
ProcessConfigFile(PGC_SIGHUP);
60+
}
61+
5462
PGSemaphoreLock(&pool->available);
5563
SpinLockAcquire(&pool->lock);
5664
if (pool->shutdown) {

tests2/support/two_nodes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
POSTGRES_USER: 'pg'
1313
POSTGRES_DB: 'regression'
1414
NODE_ID: 1
15-
MAJOR: 'on'
15+
MAJOR: 'off'
1616
CONNSTRS: >-
1717
dbname=regression user=pg host=node1,
1818
dbname=regression user=pg host=node2

tests2/test_major.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ def tearDown(self):
7272
def test_partition_major(self):
7373
print('### test_partition_major ###')
7474

75-
# MajorTest.client.execute(0, [
76-
# 'alter system set multimaster.major_node to true',
77-
# 'select pg_reload_conf();'
78-
# ])
75+
MajorTest.client.execute(0, [
76+
'alter system set multimaster.major_node to true',
77+
'select pg_reload_conf()'
78+
])
7979

8080
aggs_failure, aggs = self.performFailure(SingleNodePartition('node2'))
8181

0 commit comments

Comments
 (0)