@@ -31,6 +31,7 @@ var cfg struct {
31
31
ConnStrs ConnStrings
32
32
33
33
Verbose bool
34
+ UseDtm bool
34
35
Isolation string // "repeatable read" or "read committed"
35
36
36
37
Accounts struct {
@@ -102,6 +103,7 @@ func init() {
102
103
flag .IntVar (& cfg .Writers .Num ,"w" ,8 ,"The number of writers" )
103
104
flag .IntVar (& cfg .Writers .Updates ,"u" ,10000 ,"The number updates each writer performs" )
104
105
flag .BoolVar (& cfg .Verbose ,"v" ,false ,"Show progress and other stuff for mortals" )
106
+ flag .BoolVar (& cfg .UseDtm ,"m" ,false ,"Use DTM to keep global consistency" )
105
107
flag .BoolVar (& cfg .Writers .AllowGlobal ,"g" ,false ,"Allow global updates" )
106
108
flag .BoolVar (& cfg .Writers .AllowLocal ,"l" ,false ,"Allow local updates" )
107
109
flag .BoolVar (& cfg .Writers .PrivateRows ,"p" ,false ,"Private rows (avoid waits/aborts caused by concurrent updates of the same rows)" )
@@ -199,8 +201,10 @@ func prepare_one(connstr string, wg *sync.WaitGroup) {
199
201
200
202
defer conn .Close ()
201
203
202
- exec (conn ,"drop extension if exists pg_dtm" )
203
- exec (conn ,"create extension pg_dtm" )
204
+ if cfg .UseDtm {
205
+ exec (conn ,"drop extension if exists pg_dtm" )
206
+ exec (conn ,"create extension pg_dtm" )
207
+ }
204
208
exec (conn ,"drop table if exists t" )
205
209
exec (conn ,"create table t(u int primary key, v int)" )
206
210
@@ -318,7 +322,9 @@ func writer(id int, cCommits chan int, cAborts chan int, wg *sync.WaitGroup) {
318
322
}
319
323
320
324
// global single-node update
321
- execQuery (src ,"select dtm_begin_transaction()" )
325
+ if cfg .UseDtm {
326
+ execQuery (src ,"select dtm_begin_transaction()" )
327
+ }
322
328
323
329
// start transaction
324
330
exec (src ,"begin transaction isolation level " + cfg .Isolation )
@@ -368,8 +374,10 @@ func writer(id int, cCommits chan int, cAborts chan int, wg *sync.WaitGroup) {
368
374
continue
369
375
}
370
376
371
- xid := execQuery (src ,"select dtm_begin_transaction()" )
372
- exec (dst ,"select dtm_join_transaction($1)" ,xid )
377
+ if cfg .UseDtm {
378
+ xid := execQuery (src ,"select dtm_begin_transaction()" )
379
+ exec (dst ,"select dtm_join_transaction($1)" ,xid )
380
+ }
373
381
374
382
// start transaction
375
383
exec (src ,"begin transaction isolation level " + cfg .Isolation )
@@ -454,10 +462,12 @@ func reader(wg *sync.WaitGroup, inconsistency *bool) {
454
462
var sum int64 = 0
455
463
var xid int32
456
464
for i ,conn := range conns {
457
- if i == 0 {
458
- xid = execQuery (conn ,"select dtm_begin_transaction()" )
459
- }else {
460
- exec (conn ,"select dtm_join_transaction($1)" ,xid )
465
+ if cfg .UseDtm {
466
+ if i == 0 {
467
+ xid = execQuery (conn ,"select dtm_begin_transaction()" )
468
+ }else {
469
+ exec (conn ,"select dtm_join_transaction($1)" ,xid )
470
+ }
461
471
}
462
472
463
473
exec (conn ,"begin transaction isolation level " + cfg .Isolation )