@@ -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
@@ -317,7 +321,9 @@ func writer(id int, cCommits chan int, cAborts chan int, wg *sync.WaitGroup) {
317
321
}
318
322
319
323
// global single-node update
320
- execQuery (src ,"select dtm_begin_transaction()" )
324
+ if cfg .UseDtm {
325
+ execQuery (src ,"select dtm_begin_transaction()" )
326
+ }
321
327
322
328
// start transaction
323
329
exec (src ,"begin transaction isolation level " + cfg .Isolation )
@@ -367,8 +373,10 @@ func writer(id int, cCommits chan int, cAborts chan int, wg *sync.WaitGroup) {
367
373
continue
368
374
}
369
375
370
- xid := execQuery (src ,"select dtm_begin_transaction()" )
371
- exec (dst ,"select dtm_join_transaction($1)" ,xid )
376
+ if cfg .UseDtm {
377
+ xid := execQuery (src ,"select dtm_begin_transaction()" )
378
+ exec (dst ,"select dtm_join_transaction($1)" ,xid )
379
+ }
372
380
373
381
// start transaction
374
382
exec (src ,"begin transaction isolation level " + cfg .Isolation )
@@ -453,10 +461,12 @@ func reader(wg *sync.WaitGroup, inconsistency *bool) {
453
461
var sum int64 = 0
454
462
var xid int32
455
463
for i ,conn := range conns {
456
- if i == 0 {
457
- xid = execQuery (conn ,"select dtm_begin_transaction()" )
458
- }else {
459
- exec (conn ,"select dtm_join_transaction($1)" ,xid )
464
+ if cfg .UseDtm {
465
+ if i == 0 {
466
+ xid = execQuery (conn ,"select dtm_begin_transaction()" )
467
+ }else {
468
+ exec (conn ,"select dtm_join_transaction($1)" ,xid )
469
+ }
460
470
}
461
471
462
472
exec (conn ,"begin transaction isolation level " + cfg .Isolation )