@@ -60,34 +60,10 @@ func cmd_to_channel(argv []string, name string, out chan string) {
6060}
6161
6262const (
63- DtmHost = "127.0.0.1"
64- DtmPort = 5431
6563 PgPort = 5432
64+ RaftPort = 6543
6665)
6766
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-
9167func appendfile (filename string , lines ... string ) {
9268 f , err := os .OpenFile (filename , os .O_APPEND | os .O_WRONLY , 0600 )
9369 if err != nil {
@@ -126,36 +102,33 @@ func initdb(bin string, datadir string) {
126102 )
127103}
128104
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 ) {
139106 argv := []string {
140107 bin ,
141108 "-D" , datadir ,
142109 "-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" ,
144117 "-c" , "multimaster.conn_strings=" + strings .Join (postgresi , "," ),
145118 "-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" ,
149128 "-c" , "wal_level=logical" ,
150129 "-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" ,
159132 }
160133 name := "postgres " + datadir
161134 c := make (chan string )
@@ -207,49 +180,34 @@ func main() {
207180 prefix := get_prefix (srcroot )
208181
209182 bin := map [string ]string {
210- "arbiter" : srcroot + "/contrib/arbiter/bin/arbiter" ,
211183 "initdb" : prefix + "/bin/initdb" ,
212184 "postgres" : prefix + "/bin/postgres" ,
213185 }
214186
215187 datadirs := []string {"/tmp/data0" , "/tmp/data1" , "/tmp/data2" }
216- //arbiterdirs := []string{"/tmp/arbiter0", "/tmp/arbiter1", "/tmp/arbiter2"}
217- arbiterdirs := []string {"/tmp/arbiter0" }
218188
219189 check_bin (& bin );
220190
221191 if doInitDb {
222192 for _ , datadir := range datadirs {
223193 initdb (bin ["initdb" ], datadir )
224194 }
225- for _ , arbiterdir := range arbiterdirs {
226- initarbiter (arbiterdir )
227- }
228195 }
229196
230197 var wg sync.WaitGroup
231198
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-
241199 time .Sleep (3 * time .Second )
242200
243201 var postgresi []string
244202 for i := range datadirs {
245203 postgresi = append (
246204 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 ),
248206 )
249207 }
250208 for i , dir := range datadirs {
251209 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 )
253211 }
254212
255213 wg .Wait ()
0 commit comments