8000 Add 'UseDtm' parameter to the transfers test. · postgrespro/postgres_cluster@1ae7141 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1ae7141

Browse files
committed
Add 'UseDtm' parameter to the transfers test.
1 parent 65c7884 commit 1ae7141

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

contrib/pg_dtm/tests/transfers.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var cfg struct {
3131
ConnStrs ConnStrings
3232

3333
Verbose bool
34+
UseDtm bool
3435
Isolation string // "repeatable read" or "read committed"
3536

3637
Accounts struct {
@@ -102,6 +103,7 @@ func init() {
102103
flag.IntVar(&cfg.Writers.Num, "w", 8, "The number of writers")
103104
flag.IntVar(&cfg.Writers.Updates, "u", 10000, "The number updates each writer performs")
104105
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")
105107
flag.BoolVar(&cfg.Writers.AllowGlobal, "g", false, "Allow global updates")
106108
flag.BoolVar(&cfg.Writers.AllowLocal, "l", false, "Allow local updates")
107109
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) {
199201

200202
defer conn.Close()
201203

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+
}
204208
exec(conn, "drop table if exists t")
205209
exec(conn, "create table t(u int primary key, v int)")
206210

@@ -318,7 +322,9 @@ func writer(id int, cCommits chan int, cAborts chan int, wg *sync.WaitGroup) {
318322
}
319323

320324
// global single-node update
321-
execQuery(src, "select dtm_begin_transaction()")
325+
if cfg.UseDtm {
326+
execQuery(src, "select dtm_begin_transaction()")
327+
}
322328

323329
// start transaction
324330
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) {
368374
continue
369375
}
370376

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+
}
373381

374382
// start transaction
375383
exec(src, "begin transaction isolation level " + cfg.Isolation)
@@ -454,10 +462,12 @@ func reader(wg *sync.WaitGroup, inconsistency *bool) {
454462
var sum int64 = 0
455463
var xid int32
456464
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+
}
461471
}
462472

463473
exec(conn, "begin transaction isolation level " + cfg.Isolation)

0 commit comments

Comments
 (0)
0