@@ -60,34 +60,10 @@ func cmd_to_channel(argv []string, name string, out chan string) {
60
60
}
61
61
62
62
const (
63
- DtmHost = "127.0.0.1"
64
- DtmPort = 5431
65
63
PgPort = 5432
64
+ RaftPort = 6543
66
65
)
67
66
68
- func arbiter (bin string , datadir string , servers []string , id int , wg * sync.WaitGroup ) {
69
- argv := []string {
70
- bin ,
71
- "-d" , datadir ,
72
- "-i" , strconv .Itoa (id ),
73
- }
74
- for _ , server := range servers {
75
- argv = append (argv , "-r" , server )
76
- }
77
- log .Println (argv )
78
-
79
- name := "arbiter " + datadir
80
- c := make (chan string )
81
-
82
- go cmd_to_channel (argv , name , c )
83
-
84
- for s := range c {
85
- log .Printf ("[%s] %s\n " , name , s )
86
- }
87
-
88
- wg .Done ()
89
- }
90
-
91
67
func appendfile (filename string , lines ... string ) {
92
68
f , err := os .OpenFile (filename , os .O_APPEND | os .O_WRONLY , 0600 )
93
69
if err != nil {
@@ -126,36 +102,33 @@ func initdb(bin string, datadir string) {
126
102
)
127
103
}
128
104
129
- func initarbiter (arbiterdir string ) {
130
- if err := os .RemoveAll (arbiterdir ); err != nil {
131
- log .Fatal (err )
132
- }
133
- if err := os .MkdirAll (arbiterdir , os .ModeDir | 0777 ); err != nil {
134
- log .Fatal (err )
135
- }
136
- }
137
-
138
- func postgres (bin string , datadir string , postgresi []string , arbiters []string , port int , nodeid int , wg * sync.WaitGroup ) {
105
+ func postgres (bin string , datadir string , postgresi []string , port int , nodeid int , wg * sync.WaitGroup ) {
139
106
argv := []string {
140
107
bin ,
141
108
"-D" , datadir ,
142
109
"-p" , strconv .Itoa (port ),
143
- "-c" , "multimaster.buffer_size=65536" ,
110
+ "-c" , "autovacuum=off" ,
111
+ "-c" , "fsync=off" ,
112
+ "-c" , "max_connections=200" ,
113
+ "-c" , "max_replication_slots=10" ,
114
+ "-c" , "max_wal_senders=10" ,
115
+ "-c" , "max_worker_processes=100" ,
116
+ "-c" , "default_transaction_isolation=repeatable read" ,
144
117
"-c" , "multimaster.conn_strings=" + strings .Join (postgresi , "," ),
145
118
"-c" , "multimaster.node_id=" + strconv .Itoa (nodeid + 1 ),
146
- "-c" , "multimaster.arbiters=" + strings .Join (arbiters , "," ),
147
- "-c" , "multimaster.workers=8" ,
148
- "-c" , "multimaster.queue_size=1073741824" ,
119
+ "-c" , "multimaster.queue_size=52857600" ,
120
+ "-c" , "multimaster.workers=4" ,
121
+ "-c" , "multimaster.use_raftable=true" ,
122
+ "-c" , "multimaster.ignore_tables_without_pk=1" ,
123
+ "-c" , "multimaster.heartbeat_recv_timeout=1000" ,
124
+ "-c" , "multimaster.heartbeat_send_timeout=250" ,
125
+ "-c" , "multimaster.twopc_min_timeout=40000" ,
126
+ "-c" , "shared_preload_libraries=raftable,multimaster" ,
127
+ "-c" , "synchronous_commit=on" ,
149
128
"-c" , "wal_level=logical" ,
150
129
"-c" , "wal_sender_timeout=0" ,
151
- "-c" , "max_wal_senders=10" ,
152
- "-c" , "max_worker_processes=100" ,
153
- "-c" , "max_replication_slots=10" ,
154
- "-c" , "autovacuum=off" ,
155
- "-c" , "fsync=off" ,
156
- "-c" , "synchronous_commit=on" ,
157
- "-c" , "max_connections=200" ,
158
- "-c" , "shared_preload_libraries=multimaster" ,
130
+ "-c" , "log_checkpoints=on" ,
131
+ "-c" , "log_autovacuum_min_duration=0" ,
159
132
}
160
133
name := "postgres " + datadir
161
134
c := make (chan string )
@@ -207,49 +180,34 @@ func main() {
207
180
prefix := get_prefix (srcroot )
208
181
209
182
bin := map [string ]string {
210
- "arbiter" : srcroot + "/contrib/arbiter/bin/arbiter" ,
211
183
"initdb" : prefix + "/bin/initdb" ,
212
184
"postgres" : prefix + "/bin/postgres" ,
213
185
}
214
186
215
187
datadirs := []string {"/tmp/data0" , "/tmp/data1" , "/tmp/data2" }
216
- //arbiterdirs := []string{"/tmp/arbiter0", "/tmp/arbiter1", "/tmp/arbiter2"}
217
- arbiterdirs := []string {"/tmp/arbiter0" }
218
188
219
189
check_bin (& bin );
220
190
221
191
if doInitDb {
222
192
for _ , datadir := range datadirs {
223
193
initdb (bin ["initdb" ], datadir )
224
194
}
225
- for _ , arbiterdir := range arbiterdirs {
226
- initarbiter (arbiterdir )
227
- }
228
195
}
229
196
230
197
var wg sync.WaitGroup
231
198
232
- var arbiters []string
233
- for i := range arbiterdirs {
234
- arbiters = append (arbiters , DtmHost + ":" + strconv .Itoa (DtmPort - i ))
235
- }
236
- for i , dir := range arbiterdirs {
237
- wg .Add (1 )
238
- go arbiter (bin ["arbiter" ], dir , arbiters , i , & wg )
239
- }
240
-
241
199
time .Sleep (3 * time .Second )
242
200
243
201
var postgresi []string
244
202
for i := range datadirs {
245
203
postgresi = append (
246
204
postgresi ,
247
- fmt .Sprintf ("dbname=postgres host=127.0.0.1 port=%d sslmode=disable" , PgPort + i ),
205
+ fmt .Sprintf ("dbname=postgres host=127.0.0.1 port=%d raftport=%d sslmode=disable" , PgPort + i , RaftPort + i ),
248
206
)
249
207
}
250
208
for i , dir := range datadirs {
251
209
wg .Add (1 )
252
- go postgres (bin ["postgres" ], dir , postgresi , arbiters , PgPort + i , i , & wg )
210
+ go postgres (bin ["postgres" ], dir , postgresi , PgPort + i , i , & wg )
253
211
}
254
212
255
213
wg .Wait ()
0 commit comments