@@ -12,6 +12,8 @@ const (
12
12
INIT_AMOUNT = 10000
13
13
N_ITERATIONS = 10000
14
14
N_ACCOUNTS = TRANSFER_CONNECTIONS //100000
15
+ ISOLATION_LEVEL = "repeatable read"
16
+ //ISOLATION_LEVEL = "read committed"
15
17
)
16
18
17
19
@@ -27,6 +29,7 @@ var cfg2 = pgx.ConnConfig{
27
29
Database : "postgres" ,
28
30
}
29
31
32
+
30
33
var running = false
31
34
var nodes []int32 = []int32 {0 ,1 }
32
35
@@ -68,8 +71,8 @@ func prepare_db() {
68
71
exec (conn2 , "select dtm_join_transaction(xid))
69
72
70
73
// strt transaction
71
- exec (conn1 , "begin transaction isolation level repeatable read" )
72
- exec (conn2 , "begin transaction isolation level repeatable read" )
74
+ exec (conn1 , "begin transaction isolation level " + ISOLATION_LEVEL )
75
+ exec (conn2 , "begin transaction isolation level " + ISOLATION_LEVEL )
73
76
74
77
for i := 0 ; i < N_ACCOUNTS ; i + + {
75
78
exec (conn1 , "insert into t values($1, $2)" , i , INIT_AMOUNT )
@@ -109,8 +112,8 @@ func transfer(id int, wg *sync.WaitGroup) {
109
112
exec (conn2 , "select dtm_join_transaction(xid))
110
113
111
114
// start transaction
112
- exec (conn1 , "begin transaction isolation level repeatable read" )
113
- exec (conn2 , "begin transaction isolation level repeatable read" )
115
+ exec (conn1 , "begin transaction isolation level " + ISOLATION_LEVEL )
116
+ exec (conn2 , "begin transaction isolation level " + ISOLATION_LEVEL )
114
117
115
118
if ! execUpdate (conn1 , "update t set v = v + $1 where u=$2" , amount , account1 ) ||
116
119
! execUpdate (conn2 , "update t set v = v - $1 where u=$2" , amount , account2 ) {
@@ -144,8 +147,8 @@ func inspect(wg *sync.WaitGroup) {
144
147
xid = execQuery (conn1 , "select dtm_begin_transaction(2))
145
148
exec (conn2 , "select dtm_join_transaction(xid))
146
149
147
- exec (conn1 , "begin transaction isolation level repeatable read" )
148
- exec (conn2 , "begin transaction isolation level repeatable read" )
150
+ exec (conn1 , "begin transaction isolation level " + ISOLATION_LEVEL )
151
+ exec (conn2 , "begin transaction isolation level " + ISOLATION_LEVEL )
149
152
150
153
sum1 = execQuery (conn1 , "select sum(v) from t" )
151
154
sum2 = execQuery (conn2 , "select sum(v) from t" )
0 commit comments