Skip to content

Commit 358204a

Browse files
committed
Read Commited txs support
1 parent dc55677 commit 358204a

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

contrib/pg_xtm/pg_dtm.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ static Snapshot DtmCopySnapshot(Snapshot snapshot)
251251
static Snapshot DtmGetSnapshot()
252252
{
253253
CurrentTransactionSnapshot = GetLocalTransactionSnapshot();
254+
if (DtmGlobalTransaction && !IsolationUsesXactSnapshot()){ /* RU & RC */
255+
DtmEnsureConnection();
256+
DtmGlobalGetSnapshot(DtmConn, DtmNodeId, GetCurrentTransactionId(), &DtmSnapshot);
257+
DtmMergeSnapshots(CurrentTransactionSnapshot, &DtmSnapshot);
258+
DtmUpdateRecentXmin();
259+
}
254260
return CurrentTransactionSnapshot;
255261
}
256262

@@ -438,16 +444,20 @@ dtm_begin_transaction(PG_FUNCTION_ARGS)
438444
gtid.nNodes = ArrayGetNItems(ARR_NDIM(nodes), ARR_DIMS(nodes));
439445
DtmGlobalTransaction = true;
440446
Assert(gtid.xids[DtmNodeId] == GetCurrentTransactionId());
441-
XTM_INFO("Start transaction {%d,%d} at node %d\n", gtid.xids[0], gtid.xids[1], DtmNodeId);
447+
XTM_INFO("Start transaction {%d,%d} at node %d, iso=%d\n", gtid.xids[0], gtid.xids[1], DtmNodeId, XactIsoLevel);
442448
if (DtmNodeId == gtid.nodes[0]) {
443449
DtmEnsureConnection();
444450
DtmGlobalStartTransaction(DtmConn, &gtid);
445451
}
446-
DtmEnsureConnection();
447-
DtmGlobalGetSnapshot(DtmConn, DtmNodeId, gtid.xids[DtmNodeId], &DtmSnapshot);
448-
Assert(CurrentTransactionSnapshot != NULL);
449-
DtmMergeSnapshots(CurrentTransactionSnapshot, &DtmSnapshot);
450-
DtmUpdateRecentXmin();
452+
453+
if (IsolationUsesXactSnapshot()){ /* RR & S */
454+
DtmEnsureConnection();
455+
DtmGlobalGetSnapshot(DtmConn, DtmNodeId, gtid.xids[DtmNodeId], &DtmSnapshot);
456+
Assert(CurrentTransactionSnapshot != NULL);
457+
DtmMergeSnapshots(CurrentTransactionSnapshot, &DtmSnapshot);
458+
DtmUpdateRecentXmin();
459+
}
460+
451461
PG_RETURN_VOID();
452462
}
453463

0 commit comments

Comments
 (0)