Skip to content

Commit d1c28a2

Browse files
committed
2 parents 72cb36a + bd04aa4 commit d1c28a2

File tree

8 files changed

+43
-152
lines changed

8 files changed

+43
-152
lines changed

contrib/mmts/Cluster.pm

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,22 @@ sub psql
155155
return $node->psql(@args);
156156
}
157157

158+
sub poll
159+
{
160+
my ($self, $poller, $dbname, $pollee, $tries, $delay) = @_;
161+
my $node = $self->{nodes}->[$poller];
162+
for (my $i = 0; $i < $tries; $i++) {
163+
my $psql_out;
164+
my $pollee_plus_1 = $pollee + 1;
165+
$self->psql($poller, $dbname, "select mtm.poll_node($pollee_plus_1, true);", stdout => \$psql_out);
166+
if ($psql_out eq "t") {
167+
return 1;
168+
}
169+
my $tries_left = $tries - $i - 1;
170+
diag("$poller poll for $pollee failed [$tries_left tries left]");
171+
sleep($delay);
172+
}
173+
return 0;
174+
}
175+
158176
1;

contrib/mmts/docker/Dockerfile

Lines changed: 0 additions & 47 deletions
This file was deleted.

contrib/mmts/docker/docker-compose.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

contrib/mmts/docker/docker-entrypoint.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

contrib/mmts/multimaster.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,10 @@ static void MtmSplitConnStrs(void)
18601860
}
18611861
if (i > MAX_NODES) {
18621862
elog(ERROR, "Multimaster with more than %d nodes is not currently supported", MAX_NODES);
1863-
}
1863+
}
1864+
if (MtmNodeId > i) {
1865+
elog(ERROR, "Multimaster node id %d is out of range [%d..%d]", MtmNodeId, 1, i);
1866+
}
18641867
if (i < 2) {
18651868
elog(ERROR, "Multimaster should have at least two nodes");
18661869
}
@@ -2262,7 +2265,8 @@ _PG_init(void)
22622265

22632266
BgwPoolStart(MtmWorkers, MtmPoolConstructor);
22642267

2265-
MtmRaftableInitialize();
2268+
if (MtmUseRaftable)
2269+
MtmRaftableInitialize();
22662270
MtmArbiterInitialize();
22672271

22682272
/*

contrib/mmts/t/001_basic_recovery.pl

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use warnings;
33
use Cluster;
44
use TestLib;
5-
use Test::More tests => 4;
5+
use Test::More tests => 7;
66

77
my $cluster = new Cluster(3);
88
$cluster->init();
@@ -43,19 +43,19 @@
4343

4444
sleep(5); # Wait until failure of node will be detected
4545

46-
diag("inserting 2 on node 1");
46+
diag("inserting 2 on node 0");
4747
my $ret = $cluster->psql(0, 'postgres', "insert into t values(2, 20);"); # this transaciton may fail
4848
diag "tx1 status = $ret";
4949

50-
diag("inserting 3 on node 2");
50+
diag("inserting 3 on node 1");
5151
my $ret = $cluster->psql(1, 'postgres', "insert into t values(3, 30);"); # this transaciton may fail
5252
diag "tx2 status = $ret";
5353

54-
diag("inserting 4 on node 1 (can fail)");
54+
diag("inserting 4 on node 0 (can fail)");
5555
my $ret = $cluster->psql(0, 'postgres', "insert into t values(4, 40);");
5656
diag "tx1 status = $ret";
5757

58-
diag("inserting 5 on node 2 (can fail)");
58+
diag("inserting 5 on node 1 (can fail)");
5959
my $ret = $cluster->psql(1, 'postgres', "insert into t values(5, 50);");
6060
diag "tx2 status = $ret";
6161

@@ -73,28 +73,31 @@
7373

7474
sleep(5); # Wait until node is started
7575

76-
diag("inserting 6 on node 1 (can fail)");
76+
diag("inserting 6 on node 0 (can fail)");
7777
$cluster->psql(0, 'postgres', "insert into t values(6, 60);");
78-
diag("inserting 7 on node 2 (can fail)");
78+
diag("inserting 7 on node 1 (can fail)");
7979
$cluster->psql(1, 'postgres', "insert into t values(7, 70);");
8080

81-
$cluster->psql(0, 'postgres', "select mtm.poll_node(3);");
82-
$cluster->psql(1, 'postgres', "select mtm.poll_node(3);");
83-
$cluster->psql(2, 'postgres', "select mtm.poll_node(3);");
81+
diag("polling node 2");
82+
for (my $poller = 0; $poller < 3; $poller++) {
83+
my $pollee = 2;
84+
ok($cluster->poll($poller, 'postgres', $pollee, 10, 1), "node $pollee is online according to node $poller");
85+
}
8486

87+
diag("getting cluster state");
8588
$cluster->psql(0, 'postgres', "select * from mtm.get_cluster_state();", stdout => \$psql_out);
8689
diag("Node 1 status: $psql_out");
8790
$cluster->psql(1, 'postgres', "select * from mtm.get_cluster_state();", stdout => \$psql_out);
8891
diag("Node 2 status: $psql_out");
8992
$cluster->psql(2, 'postgres', "select * from mtm.get_cluster_state();", stdout => \$psql_out);
9093
diag("Node 3 status: $psql_out");
9194

92-
diag("inserting 8 on node 1");
95+
diag("inserting 8 on node 0");
9396
$cluster->psql(0, 'postgres', "insert into t values(8, 80);");
94-
diag("inserting 9 on node 2");
97+
diag("inserting 9 on node 1");
9598
$cluster->psql(1, 'postgres', "insert into t values(9, 90);");
9699

97-
diag("selecting from node 3");
100+
diag("selecting from node 2");
98101
$cluster->psql(2, 'postgres', "select v from t where k=8;", stdout => \$psql_out);
99102
diag("selected");
100103

contrib/mmts/tests2/docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if [ "$1" = 'postgres' ]; then
1515

1616
# look specifically for PG_VERSION, as it is expected in the DB dir
1717
if [ ! -s "$PGDATA/PG_VERSION" ]; then
18-
initdb
18+
initdb --nosync
1919

2020
if [ "$POSTGRES_PASSWORD" ]; then
2121
pass="PASSWORD '$POSTGRES_PASSWORD'"

contrib/raftable/worker.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ static int create_listening_socket(const char *host, int port)
106106
optval = 1;
107107
setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char const*)&optval, sizeof(optval));
108108
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char const*)&optval, sizeof(optval));
109-
109+
fcntl(s, F_SETFL, O_NONBLOCK);
110+
110111
elog(DEBUG1, "binding tcp %s:%d\n", host, port);
111112
if (bind(s, a->ai_addr, a->ai_addrlen) < 0)
112113
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy