Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit26ad194

Browse files
committed
Support configuration reload in logical replication workers
Author: Michael Paquier <michael.paquier@gmail.com>Reviewed-by: Petr Jelinek <petr.jelinek@2ndquadrant.com>Reported-by: Fujii Masao <masao.fujii@gmail.com>
1 parentc0a8ae7 commit26ad194

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

‎src/backend/replication/logical/launcher.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ LogicalRepCtxStruct *LogicalRepCtx;
7575
staticvoidlogicalrep_worker_onexit(intcode,Datumarg);
7676
staticvoidlogicalrep_worker_detach(void);
7777

78-
boolgot_SIGTERM= false;
78+
/* Flags set by signal handlers */
79+
volatilesig_atomic_tgot_SIGHUP= false;
80+
volatilesig_atomic_tgot_SIGTERM= false;
81+
7982
staticboolon_commit_launcher_wakeup= false;
8083

8184
Datumpg_stat_get_subscription(PG_FUNCTION_ARGS);
@@ -495,10 +498,28 @@ logicalrep_worker_onexit(int code, Datum arg)
495498
void
496499
logicalrep_worker_sigterm(SIGNAL_ARGS)
497500
{
501+
intsave_errno=errno;
502+
498503
got_SIGTERM= true;
499504

500505
/* Waken anything waiting on the process latch */
501506
SetLatch(MyLatch);
507+
508+
errno=save_errno;
509+
}
510+
511+
/* SIGHUP: set flag to reload configuration at next convenient time */
512+
void
513+
logicalrep_worker_sighup(SIGNAL_ARGS)
514+
{
515+
intsave_errno=errno;
516+
517+
got_SIGHUP= true;
518+
519+
/* Waken anything waiting on the process latch */
520+
SetLatch(MyLatch);
521+
522+
errno=save_errno;
502523
}
503524

504525
/*
@@ -637,6 +658,7 @@ ApplyLauncherMain(Datum main_arg)
637658
(errmsg("logical replication launcher started")));
638659

639660
/* Establish signal handlers. */
661+
pqsignal(SIGHUP,logicalrep_worker_sighup);
640662
pqsignal(SIGTERM,logicalrep_worker_sigterm);
641663
BackgroundWorkerUnblockSignals();
642664

@@ -728,6 +750,12 @@ ApplyLauncherMain(Datum main_arg)
728750
if (rc&WL_POSTMASTER_DEATH)
729751
proc_exit(1);
730752

753+
if (got_SIGHUP)
754+
{
755+
got_SIGHUP= false;
756+
ProcessConfigFile(PGC_SIGHUP);
757+
}
758+
731759
ResetLatch(&MyProc->procLatch);
732760
}
733761

‎src/backend/replication/logical/worker.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,12 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
11381138
if (rc&WL_POSTMASTER_DEATH)
11391139
proc_exit(1);
11401140

1141+
if (got_SIGHUP)
1142+
{
1143+
got_SIGHUP= false;
1144+
ProcessConfigFile(PGC_SIGHUP);
1145+
}
1146+
11411147
if (rc&WL_TIMEOUT)
11421148
{
11431149
/*
@@ -1441,6 +1447,7 @@ ApplyWorkerMain(Datum main_arg)
14411447
logicalrep_worker_attach(worker_slot);
14421448

14431449
/* Setup signal handling */
1450+
pqsignal(SIGHUP,logicalrep_worker_sighup);
14441451
pqsignal(SIGTERM,logicalrep_worker_sigterm);
14451452
BackgroundWorkerUnblockSignals();
14461453

‎src/include/replication/worker_internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ extern Subscription *MySubscription;
5656
externLogicalRepWorker*MyLogicalRepWorker;
5757

5858
externboolin_remote_transaction;
59-
externboolgot_SIGTERM;
59+
externvolatilesig_atomic_tgot_SIGHUP;
60+
externvolatilesig_atomic_tgot_SIGTERM;
6061

6162
externvoidlogicalrep_worker_attach(intslot);
6263
externLogicalRepWorker*logicalrep_worker_find(Oidsubid,Oidrelid,
@@ -69,6 +70,7 @@ extern void logicalrep_worker_wakeup_ptr(LogicalRepWorker *worker);
6970

7071
externintlogicalrep_sync_worker_count(Oidsubid);
7172

73+
externvoidlogicalrep_worker_sighup(SIGNAL_ARGS);
7274
externvoidlogicalrep_worker_sigterm(SIGNAL_ARGS);
7375
externchar*LogicalRepSyncTableStart(XLogRecPtr*origin_startpos);
7476
voidprocess_syncing_tables(XLogRecPtrcurrent_lsn);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp