Skip to content

Commit ddfe0c0

Browse files
committed
Fix bugs in transfer.go script
1 parent 2eeb0f3 commit ddfe0c0

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

contrib/pg_tsdtm/tests/perf/transfers.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ func (t TransfersTS) prepare_one(connstr string, wg *sync.WaitGroup) {
3939
exec(conn, "insert into t (select generate_series(0,$1-1), $2)",
4040
cfg.AccountsNum, 0)
4141

42-
exec(conn, "commit")
4342
wg.Done()
4443
}
4544

@@ -68,14 +67,18 @@ func (t TransfersTS) writer(id int, cCommits chan int, cAborts chan int, wg *syn
6867

6968
gtid := strconv.Itoa(id) + "." + strconv.Itoa(i)
7069
amount := 2*rand.Intn(2) - 1
71-
from_acc := cfg.Writers.StartId + 2*id + 1
72-
to_acc := cfg.Writers.StartId + 2*id + 2
70+
//from_acc := cfg.Writers.StartId + 2*id + 1
71+
//to_acc := cfg.Writers.StartId + 2*id + 2
72+
from_acc := rand.Intn(cfg.AccountsNum) //cfg.Writers.StartId + 2*id + 1
73+
to_acc := rand.Intn(cfg.AccountsNum) //cfg.Writers.StartId + 2*id + 2
7374

7475
conn1 := conns[rand.Intn(len(conns))]
7576
conn2 := conns[rand.Intn(len(conns))]
76-
if conn1 == conn2 {
77-
continue
78-
}
77+
78+
for conn1 == conn2 {
79+
conn1 = conns[rand.Intn(len(conns))]
80+
conn2 = conns[rand.Intn(len(conns))]
81+
}
7982

8083
exec(conn1, "begin transaction")
8184
exec(conn2, "begin transaction")
@@ -134,9 +137,6 @@ func (t TransfersTS) reader(wg *sync.WaitGroup, cFetches chan int, inconsistency
134137
snapshot = _execQuery(conn, "select dtm_access($1)", snapshot)
135138
}
136139
}
137-
138-
exec(conn, "begin transaction isolation level " + cfg.Isolation)
139-
sum += _execQuery(conn, "select sum(v) from t")
140140
}
141141

142142
for _, conn := range conns {

contrib/pg_tsdtm/tests/transfers.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ import (
1010
)
1111

1212
const (
13-
TRANSFER_CONNECTIONS = 10
13+
TRANSFER_CONNECTIONS = 100
1414
INIT_AMOUNT = 10000
15-
N_ITERATIONS = 10000
15+
N_ITERATIONS = 1000
1616
N_ACCOUNTS = 100000
1717
)
1818

1919

2020
var cfg1 = pgx.ConnConfig{
21-
Host: "astro9",
22-
Port: 15432,
21+
Host: "127.0.0.1",
22+
Port: 5432,
2323
Database: "postgres",
2424
}
2525

2626
var cfg2 = pgx.ConnConfig{
27-
Host: "astro9",
28-
Port: 15433,
27+
Host: "127.0.0.1",
28+
Port: 5433,
2929
Database: "postgres",
3030
}
3131

@@ -109,8 +109,8 @@ func transfer(id int, wg *sync.WaitGroup) {
109109

110110
gtid := strconv.Itoa(id) + "." + strconv.Itoa(i)
111111
amount := 2*rand.Intn(2) - 1
112-
account1 := 2*id+1
113-
account2 := 2*id+2
112+
account1 := rand.Intn(N_ACCOUNTS)
113+
account2 := rand.Intn(N_ACCOUNTS)
114114

115115
exec(conn1, "begin transaction")
116116
exec(conn2, "begin transaction")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy