Skip to content

Commit 5f43df1

Browse files
committed
tap-test for mm recovery
1 parent 3c1860a commit 5f43df1

File tree

3 files changed

+135
-4
lines changed

3 files changed

+135
-4
lines changed

contrib/mmts/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ include $(top_builddir)/src/Makefile.global
2222
include $(top_srcdir)/contrib/contrib-global.mk
2323
endif
2424

25+
check:
26+
env DESTDIR='$(abs_top_builddir)'/tmp_install make install
27+
$(prove_check)
28+

contrib/mmts/TODO

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
TODO
22

3-
* Disallow tables without pkeys.
3+
* Disallow or do not replicate tables without pkeys.
44
* Automate extension creation (?)
55
* Database itn't usable right after pg_ctl -w. There are still several second before db will switch to operational mode.
6-
* Statements without tx.
6+
+ Statements without tx.
77
* Disallow user-created MTM-* gid's.
8-
9-
8+
* Check configuration sanity for mm before actual startup: max_wal_senders, max_worker_processes, max_wal_senders, wal_level, max_replication_slots
9+
* Handle SIGQUIT
10+
* Move arbiter host/port to connstring
1011

1112

1213

contrib/mmts/t/001_basic_recovery.pl

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
use strict;
2+
use warnings;
3+
use PostgresNode;
4+
use TestLib;
5+
use Test::More tests => 2;
6+
use DBI;
7+
use DBD::Pg ':async';
8+
9+
###############################################################################
10+
# Aux routines
11+
###############################################################################
12+
13+
sub PostgresNode::inet_connstr {
14+
my ($self, $dbname) = @_;
15+
my $pgport = $self->port;
16+
my $pghost = '127.0.0.1';
17+
my $pgdata = $self->data_dir;
18+
19+
if (!defined($dbname))
20+
{
21+
return "port=$pgport host=$pghost";
22+
}
23+
return "port=$pgport host=$pghost dbname=$dbname";
24+
}
25+
26+
###############################################################################
27+
# Setup nodes
28+
###############################################################################
29+
30+
my $nnodes = 3;
31+
my @nodes = ();
32+
my $pgconf_common = qq(
33+
listen_addresses = '127.0.0.1'
34+
max_prepared_transactions = 10
35+
max_worker_processes = 10
36+
max_wal_senders = 10
37+
max_replication_slots = 10
38+
wal_level = logical
39+
shared_preload_libraries = 'multimaster'
40+
multimaster.workers=4
41+
multimaster.queue_size=10485760 # 10mb
42+
);
43+
44+
# Init nodes
45+
for (my $i=0; $i < $nnodes; $i++) {
46+
push(@nodes, get_new_node("node$i"));
47+
$nodes[$i]->init;
48+
}
49+
50+
# Collect conn info
51+
my $mm_connstr = join(', ', map { "${ \$_->inet_connstr('postgres') }" } @nodes);
52+
53+
# Configure and start nodes
54+
for (my $i=0; $i < $nnodes; $i++) {
55+
$nodes[$i]->append_conf('postgresql.conf', $pgconf_common);
56+
$nodes[$i]->append_conf('postgresql.conf', qq(
57+
multimaster.node_id = @{[ $i + 1 ]}
58+
multimaster.conn_strings = '$mm_connstr'
59+
#multimaster.arbiter_port = ${ \$nodes[0]->port }
60+
));
61+
$nodes[$i]->append_conf('pg_hba.conf', qq(
62+
host replication all 127.0.0.1/32 trust
63+
));
64+
$nodes[$i]->start;
65+
}
66+
67+
###############################################################################
68+
# Wait until nodes are up
69+
###############################################################################
70+
71+
my $psql_out;
72+
# XXX: change to poll_untill
73+
sleep(7);
74+
75+
###############################################################################
76+
# Replication check
77+
###############################################################################
78+
79+
$nodes[0]->psql('postgres', "
80+
create extension multimaster;
81+
create table if not exists t(k int primary key, v int);
82+
insert into t values(1, 10);
83+
");
84+
85+
$nodes[1]->psql('postgres', "select v from t where k=1;", stdout => \$psql_out);
86+
is($psql_out, '10', "Check sanity while all nodes are up.");
87+
88+
###############################################################################
89+
# Isolation regress checks
90+
###############################################################################
91+
92+
# we can call pg_regress here
93+
94+
###############################################################################
95+
# Work after node stop
96+
###############################################################################
97+
98+
$nodes[2]->teardown_node;
99+
100+
# $nodes[0]->poll_query_until('postgres',
101+
# "select disconnected = true from mtm.get_nodes_state() where id=3;")
102+
# or die "Timed out while waiting for node to disconnect";
103+
104+
$nodes[0]->psql('postgres', "
105+
insert into t values(2, 20);
106+
");
107+
108+
$nodes[1]->psql('postgres', "select v from t where k=2;", stdout => \$psql_out);
109+
is($psql_out, '20', "Check that we can commit after one node disconnect.");
110+
111+
112+
113+
114+
115+
116+
117+
118+
119+
120+
121+
122+
123+
124+
125+
126+

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