@@ -15,6 +15,8 @@ const (
15
15
N_ACCOUNTS = TRANSFER_CONNECTIONS //100000
16
16
//ISOLATION_LEVEL = "repeatable read"
17
17
ISOLATION_LEVEL = "read committed"
18
+ GLOBAL_UPDATES = true
19
+ LOCAL_UPDATES = false
18
20
)
19
21
20
22
@@ -132,11 +134,20 @@ func transfer(id int, cCommits chan int, cAborts chan int, wg *sync.WaitGroup) {
132
134
account1 := rand .Intn (N_ACCOUNTS )
133
135
account2 := rand .Intn (N_ACCOUNTS )
134
136
137
+ if (account1 >= account2 ) {
138
+ continue
139
+ }
140
+
135
141
src := conn [rand .Intn (2 )]
136
142
dst := conn [rand .Intn (2 )]
137
143
138
144
if src == dst {
139
- // local transaction
145
+ // local update
146
+ if ! LOCAL_UPDATES {
147
+ // which we do not want
148
+ continue
149
+ }
150
+
140
151
exec (src , "begin transaction isolation level " + ISOLATION_LEVEL )
141
152
ok1 := execUpdate (src , "update t set v = v - $1 where u=$2" , amount , account1 )
142
153
ok2 := execUpdate (src , "update t set v = v + $1 where u=$2" , amount , account2 )
@@ -149,7 +160,12 @@ func transfer(id int, cCommits chan int, cAborts chan int, wg *sync.WaitGroup) {
149
160
myCommits += 1
150
161
}
151
162
} else {
152
- // global transaction
163
+ // global update
164
+ if ! GLOBAL_UPDATES {
165
+ // which we do not want
166
+ continue
167
+ }
168
+
153
169
xid = execQuery (src , "select dtm_begin_transaction(2)" )
154
170
exec (dst , "select dtm_join_transaction($1)" , xid )
155
171
@@ -263,6 +279,9 @@ func execUpdate(conn *pgx.Conn, stmt string, arguments ...interface{}) bool {
263
279
var err error
264
280
// fmt.Println(stmt)
265
281
_ , err = conn .Exec (stmt , arguments ... )
282
+ if err != nil {
283
+ fmt .Println (err )
284
+ }
266
285
return err == nil
267
286
}
268
287
0 commit comments