Skip to content

Commit 935dac5

Browse files
committed
test with splits
1 parent 294238c commit 935dac5

File tree

10 files changed

+110
-68
lines changed

10 files changed

+110
-68
lines changed

contrib/mmts/testeaux/RemoteCluster.pm renamed to contrib/mmts/testeaux/lib/RemoteCluster.pm

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,21 @@ sub configure
8080
max_wal_senders = 10
8181
wal_sender_timeout = 0
8282
max_replication_slots = 10
83+
84+
tcp_keepalives_idle = 2
85+
tcp_keepalives_interval = 1
86+
tcp_keepalives_count = 2
87+
8388
shared_preload_libraries = 'raftable,multimaster'
8489
multimaster.workers = 10
8590
multimaster.queue_size = 10485760 # 10mb
8691
multimaster.node_id = $id
8792
multimaster.conn_strings = '$connstr'
88-
multimaster.use_raftable = true
93+
multimaster.use_raftable = false
8994
multimaster.ignore_tables_without_pk = true
9095
multimaster.twopc_min_timeout = 60000
96+
multimaster.twopc_prepare_ratio = 1000 #%
97+
9198
raftable.id = $id
9299
raftable.peers = '$raftpeers'
93100
));
@@ -130,9 +137,9 @@ sub psql
130137
}
131138

132139
# XXX: test
133-
my $cluster = new RemoteCluster('ssh-config');
134-
$cluster->init;
135-
$cluster->configure;
136-
$cluster->start;
137-
140+
#my $cluster = new RemoteCluster('ssh-config');
141+
# $cluster->init;
142+
# $cluster->configure;
143+
# $cluster->start;
144+
#
138145
1;

contrib/mmts/testeaux/RemoteNode.pm renamed to contrib/mmts/testeaux/lib/RemoteNode.pm

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package RemoteNode;
33
use strict;
44
use warnings;
55
use Net::OpenSSH;
6+
use IPC::Run;
67

78
sub new
89
{
@@ -24,9 +25,8 @@ sub new
2425

2526
bless $self, $class;
2627

27-
# kill postgres here to ensure
28-
# predictable initial state.
29-
$self->execute("pkill -9 postgres || true");
28+
$self->execute("sudo iptables -F");
29+
$self->execute("sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT");
3030

3131
return $self;
3232
}
@@ -35,7 +35,7 @@ sub connstr
3535
{
3636
my ($self, $dbname) = @_;
3737

38-
"host=$self->{_host} dbname=$dbname";
38+
"host=$self->{_host} dbname=$dbname user=$self->{_user}";
3939
}
4040

4141
sub execute
@@ -71,6 +71,10 @@ sub init
7171
my $pgbin = $self->{_pgbin};
7272
my $pgdata = $self->{_pgdata};
7373

74+
# kill postgres here to ensure
75+
# predictable initial state.
76+
$self->execute("pkill -9 postgres || true");
77+
7478
$self->execute("rm -rf $pgdata");
7579
$self->execute("env LANG=C LC_ALL=C $pgbin/initdb -D $pgdata -A trust -N");
7680

@@ -114,4 +118,42 @@ sub append_conf
114118
$self->execute($cmd);
115119
}
116120

121+
sub psql
122+
{
123+
my ($self, $dbname, $sql) = @_;
124+
my $stderr;
125+
my $stdout;
126+
127+
my @psql_command =
128+
('psql', '-XAtq', '-d', $self->connstr($dbname), '-f', '-');
129+
130+
my @ipcrun_command = (\@psql_command, '<', \$sql);
131+
#push @ipcrun_command, '>', $stdout;
132+
#push @ipcrun_command, '2>', $stderr;
133+
134+
IPC::Run::run @ipcrun_command;
135+
my $ret = $?;
136+
137+
return $ret;
138+
}
139+
140+
sub net_deny_in
141+
{
142+
my ($self) = @_;
143+
$self->execute("sudo iptables -A INPUT -j DROP");
144+
}
145+
146+
sub net_deny_out
147+
{
148+
my ($self) = @_;
149+
$self->execute("sudo iptables -A OUTPUT -j DROP");
150+
}
151+
152+
sub net_allow
153+
{
154+
my ($self) = @_;
155+
$self->execute("sudo iptables -D INPUT -j DROP");
156+
$self->execute("sudo iptables -D OUTPUT -j DROP");
157+
}
158+
117159
1;

contrib/mmts/testeaux/provision.yml

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,66 +3,9 @@
33
- hosts: all
44

55
roles:
6-
- role: kelvich.postgres
6+
- role: postgres
77
pg_port: 5432
88
pg_repo: https://github.com/postgrespro/postgres_cluster.git
99
pg_version_tag: master
1010
pg_destroy_and_init: true
11-
pg_config_role:
12-
- line: "multimaster.buffer_size = 65536"
13-
14-
tasks:
15-
- name: generate connstrings
16-
set_fact:
17-
connstr: "host={{item}} user={{ansible_ssh_user}} dbname=postgres"
18-
with_items:
19-
groups['all'] | reverse | batch(nnodes | d(3) | int) | first
20-
register: connstrs
21-
22-
- name: make a list
23-
set_fact:
24-
connections: "{{ connstrs.results | map(attribute='ansible_facts.connstr') | join(', ') }}"
25-
26-
- debug: var=hostvars
27-
28-
- debug: var=inventory_hostname
29-
30-
#- debug: var=hostvars[inventory_hostname]
31-
32-
- name: build raftable
33-
shell: "make clean && make -j {{makejobs}} install"
34-
args:
35-
chdir: "{{pg_src}}/contrib/raftable"
36-
37-
- name: build multimaster
38-
shell: "make clean && make -j {{makejobs}} install"
39-
args:
40-
chdir: "{{pg_src}}/contrib/mmts"
41-
42-
- name: enable dtm extension on datanodes
43-
lineinfile:
44-
dest: "{{pg_datadir}}/postgresql.conf"
45-
line: "{{item}}"
46-
state: present
47-
with_items:
48-
- "wal_level = logical"
49-
- "max_wal_senders = 10"
50-
- "wal_sender_timeout = 0"
51-
- "max_replication_slots = 10"
52-
- "max_connections = 200"
53-
- "max_worker_processes = 100"
54-
- "shared_preload_libraries = 'raftable,multimaster'"
55-
- "multimaster.conn_strings = '{{connections}}'"
56-
- "multimaster.node_id = {{ inventory_hostname | regex_replace('([0-9]+)', '\\1') }}"
57-
- "multimaster.buffer_size = 65536"
58-
- "multimaster.queue_size = 1073741824"
59-
- "multimaster.arbiter_port = 5600"
60-
- "multimaster.vacuum_delay = 1"
61-
- "multimaster.workers = 32"
62-
- "multimaster.use_dtm = 1"
63-
64-
- name: restart postgrespro
65-
command: "{{pg_dst}}/bin/pg_ctl restart -w -D {{pg_datadir}} -l {{pg_datadir}}/pg.log"
66-
environment:
67-
LD_LIBRARY_PATH: "{{pg_dst}}/lib/"
6811

contrib/mmts/testeaux/roles/postgres

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 51e6d51571c89e5dc51b332a84cf11eb945d130c

contrib/mmts/testeaux/run_splits.pl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use strict;
2+
use warnings;
3+
4+
use lib 'lib';
5+
use RemoteCluster;
6+
use IPC::Run;
7+
8+
my $cluster = new RemoteCluster('ssh-config');
9+
$cluster->init;
10+
$cluster->configure;
11+
$cluster->start;
12+
sleep 10;
13+
14+
$cluster->{nodes}->[0]->psql('postgres','create extension if not exists multimaster');
15+
$cluster->{nodes}->[0]->psql('postgres','select * from mtm.get_nodes_state();');
16+
17+
print("Initializing database\n");
18+
IPC::Run::run (
19+
'pgbench',
20+
'-i',
21+
-h => $cluster->{nodes}->[0]->{_host},
22+
-U => $cluster->{nodes}->[0]->{_user},
23+
'postgres'
24+
);
25+
26+
my $pgbench1 = IPC::Run::start (
27+
'pgbench',
28+
-c => 4,
29+
-T => 30,
30+
-P => 1,
31+
-h => $cluster->{nodes}->[0]->{_host},
32+
-U => $cluster->{nodes}->[0]->{_user},
33+
'postgres'
34+
);
35+
36+
sleep 5;
37+
$cluster->{nodes}->[0]->net_deny_in;
38+
sleep 10;
39+
$cluster->{nodes}->[0]->net_allow;
40+
41+
42+
IPC::Run::finish($pgbench1);
43+
# IPC::Run::run @pgbench_init
44+
45+
46+
47+
48+
49+

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