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

Commit4cb7f37

Browse files
kvapkelvich
authored andcommitted
Add stop-signal handling to arbiter.
1 parent69d8f41 commit4cb7f37

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

‎arbiter.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ MtmResolveHostByName(const char *hostname, unsigned* addrs, unsigned* n_addrs)
164164
return1;
165165
}
166166

167+
staticintstop=0;
168+
staticvoidSetStop(intsig)
169+
{
170+
stop=1;
171+
}
172+
167173
#ifUSE_EPOLL
168174
staticintepollfd;
169175
#else
@@ -530,17 +536,24 @@ static void MtmBroadcastMessage(MtmBuffer* txBuffer, MtmTransState* ts)
530536

531537
staticvoidMtmTransSender(Datumarg)
532538
{
539+
sigset_tsset;
533540
intnNodes=MtmNodes;
534541
inti;
535542
MtmBuffer*txBuffer= (MtmBuffer*)palloc(sizeof(MtmBuffer)*nNodes);
536-
543+
544+
signal(SIGINT,SetStop);
545+
signal(SIGQUIT,SetStop);
546+
signal(SIGTERM,SetStop);
547+
sigfillset(&sset);
548+
sigprocmask(SIG_UNBLOCK,&sset,NULL);
549+
537550
MtmOpenConnections();
538551

539552
for (i=0;i<nNodes;i++) {
540553
txBuffer[i].used=0;
541554
}
542555

543-
while (true) {
556+
while (!stop) {
544557
MtmTransState*ts;
545558
PGSemaphoreLock(&Mtm->votingSemaphore);
546559
CHECK_FOR_INTERRUPTS();
@@ -605,6 +618,7 @@ static bool MtmRecovery()
605618

606619
staticvoidMtmTransReceiver(Datumarg)
607620
{
621+
sigset_tsset;
608622
intnNodes=MtmNodes;
609623
intnResponses;
610624
inti,j,n,rc;
@@ -617,14 +631,20 @@ static void MtmTransReceiver(Datum arg)
617631
FD_ZERO(&inset);
618632
max_fd=0;
619633
#endif
634+
635+
signal(SIGINT,SetStop);
636+
signal(SIGQUIT,SetStop);
637+
signal(SIGTERM,SetStop);
638+
sigfillset(&sset);
639+
sigprocmask(SIG_UNBLOCK,&sset,NULL);
620640

621641
MtmAcceptIncomingConnections();
622642

623643
for (i=0;i<nNodes;i++) {
624644
rxBuffer[i].used=0;
625645
}
626646

627-
while (true) {
647+
while (!stop) {
628648
#ifUSE_EPOLL
629649
n=epoll_wait(epollfd,events,nNodes,MtmKeepaliveTimeout/1000);
630650
if (n<0) {

‎t/000_deadlock.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ sub allocate_ports
5656
return@allocated_now;
5757
}
5858

59-
my$nnodes =3;
59+
my$nnodes =2;
6060
my@nodes = ();
6161

6262
# Create nodes and allocate ports

‎t/001_basic_recovery.pl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,27 @@ sub PostgresNode::inet_connstr {
9696

9797
$nodes[2]->teardown_node;
9898

99+
diag("sleeping");
100+
sleep(15);
101+
102+
diag("inserting 2");
99103
$nodes[0]->psql('postgres',"insert into t values(2, 20);");
104+
diag("selecting");
100105
$nodes[1]->psql('postgres',"select v from t where k=2;",stdout=> \$psql_out);
106+
diag("selected");
101107
is($psql_out,'20',"Check replication after node failure.");
102108

103109
###############################################################################
104110
# Work after node start
105111
###############################################################################
106112

107113
$nodes[2]->start;
108-
sleep(5);# XXX: here we can poll
114+
sleep(15);# XXX: here we can poll
115+
diag("inserting 3");
109116
$nodes[0]->psql('postgres',"insert into t values(3, 30);");
117+
diag("selecting");
110118
$nodes[2]->psql('postgres',"select v from t where k=3;",stdout=> \$psql_out);
119+
diag("selected");
111120
is($psql_out,'30',"Check replication after failed node recovery.");
112121

113122

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp