@@ -77,8 +77,8 @@ func prepare_db() {
7777 exec (conn2 , "select dtm_begin_transaction($1, $2)" , nodes , xids )
7878
7979 // first global statement
80- // exec(conn1, "select dtm_get_snapshot()")
81- // exec(conn2, "select dtm_get_snapshot()")
80+ exec (conn1 , "select dtm_get_snapshot()" )
81+ exec (conn2 , "select dtm_get_snapshot()" )
8282
8383 for i := 0 ; i < N_ACCOUNTS ; i ++ {
8484 exec (conn1 , "insert into t values($1, $2)" , i , INIT_AMOUNT )
@@ -97,6 +97,7 @@ func max(a, b int64) int64 {
9797
9898func transfer (id int , wg * sync.WaitGroup ) {
9999 var err error
100+ var sum1 , sum2 , sum int32
100101 var xids []int32 = make ([]int32 , 2 )
101102
102103 conn1 , err := pgx .Connect (cfg1 )
@@ -126,12 +127,29 @@ func transfer(id int, wg *sync.WaitGroup) {
126127 exec (conn2 , "select dtm_begin_transaction($1, $2)" , nodes , xids )
127128
128129 // first global statement
129- // exec(conn1, "select dtm_get_snapshot()")
130- // exec(conn2, "select dtm_get_snapshot()")
130+ exec (conn1 , "select dtm_get_snapshot()" )
131+ exec (conn2 , "select dtm_get_snapshot()" )
132+
133+ sum1 = execQuery (conn1 , "select sum(v) from t" )
134+ sum2 = execQuery (conn2 , "select sum(v) from t" )
135+ sum = sum1 + sum2
131136
137+ exec (conn1 , "select dtm_get_snapshot()" )
138+ exec (conn2 , "select dtm_get_snapshot()" )
139+
132140 exec (conn1 , "update t set v = v + $1 where u=$2" , amount , account1 )
133141 exec (conn2 , "update t set v = v - $1 where u=$2" , amount , account2 )
142+
143+ exec (conn1 , "select dtm_get_snapshot()" )
144+ exec (conn2 , "select dtm_get_snapshot()" )
134145
146+ sum1 = execQuery (conn1 , "select sum(v) from t" )
147+ sum2 = execQuery (conn2 , "select sum(v) from t" )
148+
149+ if (sum1 + sum2 != sum ) {
150+ fmt .Println ("Before = " , sum , ", after=" , sum1 + sum2 , ", xids=" , xids )
151+ }
152+
135153 commit (conn1 , conn2 )
136154 }
137155
0 commit comments