Skip to content

Commit b92769c

Browse files
committed
Update script
1 parent fb68d82 commit b92769c

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

contrib/pg_xtm/pg_dtm.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static DTMConn DtmConn;
5959

6060
#define XTM_TRACE(fmt, ...)
6161
//#define XTM_TRACE(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
62-
#define XTM_INFO(fmt, ...) elog(WARNING, fmt, ## __VA_ARGS__)
62+
#define XTM_INFO(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
6363
#define XTM_CONNECT_ATTEMPTS 10
6464

6565
static void DtmEnsureConnection(void)
@@ -310,7 +310,6 @@ dtm_get_snapshot(PG_FUNCTION_ARGS)
310310
DtmGlobalGetSnapshot(DtmConn, DtmNodeId, GetCurrentTransactionId(), &DtmSnapshot);
311311

312312
XTM_TRACE("XTM: dtm_get_snapshot \n");
313-
Assert(!DtmHasSnapshot);
314313
DtmHasSnapshot = true;
315314
DtmGlobalTransaction = true;
316315
PG_RETURN_VOID();

contrib/pg_xtm/tests/transfers.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

9898
func 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

Comments
 (0)