@@ -22,15 +22,15 @@ sub query_exec
22
22
{
23
23
my ($dbi , $sql ) = @_ ;
24
24
my $rv = $dbi -> do($sql ) || die ;
25
- print " query_exec('$sql ')\n " ;
25
+ print " query_exec('$sql ') = $rv \n " ;
26
26
return $rv ;
27
27
}
28
28
29
29
sub query_exec_async
30
30
{
31
31
my ($dbi , $sql ) = @_ ;
32
32
my $rv = $dbi -> do($sql , {pg_async => PG_ASYNC}) || die ;
33
- print " query_exec ('$sql ')\n " ;
33
+ print " query_exec_async ('$sql ') = $rv \n " ;
34
34
return $rv ;
35
35
}
36
36
@@ -56,7 +56,7 @@ sub allocate_ports
56
56
return @allocated_now ;
57
57
}
58
58
59
- my $nnodes = 2 ;
59
+ my $nnodes = 3 ;
60
60
my @nodes = ();
61
61
62
62
# Create nodes and allocate ports
@@ -89,22 +89,19 @@ sub allocate_ports
89
89
listen_addresses = '$host '
90
90
unix_socket_directories = ''
91
91
port = $pgport
92
- max_connections = 200
93
- shared_buffers = 1GB
94
- max_prepared_transactions = 200
95
- max_worker_processes = 100
92
+ max_prepared_transactions = 10
93
+ max_worker_processes = 10
96
94
wal_level = logical
97
95
fsync = off
98
- max_wal_size = 100GB
99
- min_wal_size = 1GB
100
96
max_wal_senders = 10
101
97
wal_sender_timeout = 0
102
98
max_replication_slots = 10
103
99
shared_preload_libraries = 'raftable,multimaster'
104
- multimaster.workers = 8
105
- multimaster.queue_size = 104857600 # 100mb
100
+ multimaster.workers = 4
101
+ multimaster.queue_size = 10485760 # 10mb
106
102
multimaster.node_id = $id
107
103
multimaster.conn_strings = '$mm_connstr '
104
+ multimaster.use_raftable = true
108
105
raftable.id = $id
109
106
raftable.peers = '$raft_peers '
110
107
) );
@@ -122,27 +119,39 @@ sub allocate_ports
122
119
$node -> start();
123
120
}
124
121
125
- $nodes [0] -> psql( " create table t(k int primary key, v text) " );
126
- $nodes [0] -> psql( " insert into t values (1, 'hello'), (2, 'world') " );
122
+ my ( $rc , $out , $err );
123
+ sleep (10 );
127
124
128
- # my @conns = map { DBI->connect('DBI:Pg:' . $_->connstr()) } @nodes;
129
- #
130
- # query_exec($conns[0], "begin");
131
- # query_exec($conns[1], "begin");
132
- #
133
- # query_exec($conns[0], "update t set v = 'foo' where k = 1");
134
- # query_exec($conns[1], "update t set v = 'bar' where k = 2");
135
- #
136
- # query_exec($conns[0], "update t set v = 'bar' where k = 2");
137
- # query_exec($conns[1], "update t set v = 'foo' where k = 1");
138
- #
139
- # query_exec_async($conns[0], "commit");
140
- # query_exec_async($conns[1], "commit");
141
- #
142
- # my $ready = 0;
143
- # $ready++ if $conns[0]->pg_ready;
144
- # $ready++ if $conns[1]->pg_ready;
145
- #
146
- # is($ready, 1, "one of the connections is deadlocked");
125
+ $nodes [0]-> psql(' postgres' , " create table t(k int primary key, v text)" );
126
+ $nodes [0]-> psql(' postgres' , " insert into t values (1, 'hello'), (2, 'world')" );
127
+
128
+ # sub space2semicol
129
+ # {
130
+ # my $str = shift;
131
+ # $str =~ tr/ /;/;
132
+ # return $str;
133
+ # }
147
134
#
135
+ my @conns = map { DBI-> connect (' DBI:Pg:' . $_ -> connstr()) } @nodes ;
136
+
137
+ query_exec($conns [0], " begin" );
138
+ query_exec($conns [1], " begin" );
139
+
140
+ query_exec($conns [0], " update t set v = 'asd' where k = 1" );
141
+ query_exec($conns [1], " update t set v = 'bsd' where k = 2" );
142
+
143
+ query_exec($conns [0], " update t set v = 'bar' where k = 2" );
144
+ query_exec($conns [1], " update t set v = 'foo' where k = 1" );
145
+
146
+ query_exec_async($conns [0], " commit" );
147
+ query_exec_async($conns [1], " commit" );
148
+
149
+ for my $i (1..2)
150
+ {
151
+ ($rc , $out , $err ) = $nodes [$i ]-> psql(' postgres' , " select * from t" );
152
+ print (" rc[$i ] = $rc \n " );
153
+ print (" out[$i ] = $out \n " );
154
+ print (" err[$i ] = $err \n " );
155
+ }
156
+
148
157
# sleep(2);
0 commit comments