Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1ae7141

Browse files
committed
Add 'UseDtm' parameter to the transfers test.
1 parent65c7884 commit1ae7141

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
ConnStrsConnStrings
3232

3333
Verbosebool
34+
UseDtmbool
3435
Isolationstring// "repeatable read" or "read committed"
3536

3637
Accountsstruct {
@@ -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
deferconn.Close()
201203

202-
exec(conn,"drop extension if exists pg_dtm")
203-
exec(conn,"create extension pg_dtm")
204+
ifcfg.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+
ifcfg.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+
ifcfg.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
varsumint64=0
455463
varxidint32
456464
fori,conn:=rangeconns {
457-
ifi==0 {
458-
xid=execQuery(conn,"select dtm_begin_transaction()")
459-
}else {
460-
exec(conn,"select dtm_join_transaction($1)",xid)
465+
ifcfg.UseDtm {
466+
ifi==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)

[8]ページ先頭

©2009-2025 Movatter.jp