Skip to content

Commit 685a409

Browse files
committed
Use two phase commit
1 parent 07cd7a1 commit 685a409

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pg_dtm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
632632
LWLockAcquire(dtm->hashLock, LW_EXCLUSIVE);
633633
hash_search(xid_in_doubt, &DtmNextXid, HASH_ENTER, NULL);
634634
LWLockRelease(dtm->hashLock);
635-
DtmGlobalSetTransStatus(xid, status, true);
635+
while (DtmGlobalSetTransStatus(xid, status, false) < 0);
636636
XTM_INFO("Commit transaction %d\n", xid);
637637
}
638638
}

tests/dtmbench.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ void* writer(void* arg)
194194
continue;
195195
}
196196

197+
#if 1
198+
exec(srcTx, "prepare transaction '%u'", xid);
199+
exec(dstTx, "prepare transaction '%u'", xid);
200+
exec(srcTx, "commit prepared '%u'", xid);
201+
exec(dstTx, "commit prepared '%u'", xid);
202+
#else
197203
pipeline srcPipe(srcTx);
198204
pipeline dstPipe(dstTx);
199205
@@ -202,7 +208,7 @@ void* writer(void* arg)
202208
203209
srcPipe.complete();
204210
dstPipe.complete();
205-
211+
#endif
206212
t.proceeded += 1;
207213
}
208214
return NULL;

0 commit comments

Comments
 (0)