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

Commitd6559e2

Browse files
committed
2 parentse436c65 +1ae7141 commitd6559e2

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

@@ -317,7 +321,9 @@ func writer(id int, cCommits chan int, cAborts chan int, wg *sync.WaitGroup) {
317321
}
318322

319323
// global single-node update
320-
execQuery(src,"select dtm_begin_transaction()")
324+
ifcfg.UseDtm {
325+
execQuery(src,"select dtm_begin_transaction()")
326+
}
321327

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

370-
xid:=execQuery(src,"select dtm_begin_transaction()")
371-
exec(dst,"select dtm_join_transaction($1)",xid)
376+
ifcfg.UseDtm {
377+
xid:=execQuery(src,"select dtm_begin_transaction()")
378+
exec(dst,"select dtm_join_transaction($1)",xid)
379+
}
372380

373381
// start transaction
374382
exec(src,"begin transaction isolation level "+cfg.Isolation)
@@ -453,10 +461,12 @@ func reader(wg *sync.WaitGroup, inconsistency *bool) {
453461
varsumint64=0
454462
varxidint32
455463
fori,conn:=rangeconns {
456-
ifi==0 {
457-
xid=execQuery(conn,"select dtm_begin_transaction()")
458-
}else {
459-
exec(conn,"select dtm_join_transaction($1)",xid)
464+
ifcfg.UseDtm {
465+
ifi==0 {
466+
xid=execQuery(conn,"select dtm_begin_transaction()")
467+
}else {
468+
exec(conn,"select dtm_join_transaction($1)",xid)
469+
}
460470
}
461471

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp