Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc142ba

Browse files
committed
Support subtransactions
1 parente37ec91 commitfc142ba

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

‎pg_dtm.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include"access/xact.h"
2222
#include"access/xtm.h"
2323
#include"access/transam.h"
24+
#include"access/subtrans.h"
2425
#include"access/xlog.h"
2526
#include"access/clog.h"
2627
#include"access/twophase.h"
@@ -455,7 +456,10 @@ bool DtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
455456
#endif
456457
while (true)
457458
{
458-
DtmTransStatus*ts= (DtmTransStatus*)hash_search(xid2status,&xid,HASH_FIND,NULL);
459+
DtmTransStatus*ts;
460+
TransactionIdsubxid=xid;
461+
while ((ts= (DtmTransStatus*)hash_search(xid2status,&subxid,HASH_FIND,NULL))==NULL
462+
&&TransactionIdIsValid(subxid=SubTransGetParent(subxid)));
459463
if (ts!=NULL)
460464
{
461465
if (ts->cid>dtm_tx.snapshot) {

‎tests/dtmbench.cpp‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct config
6868
nWriters =10;
6969
nIterations =1000;
7070
nAccounts =100000;
71-
startId =1;
71+
startId =0;
7272
diapason =100000;
7373
}
7474
};
@@ -177,7 +177,10 @@ void* writer(void* arg)
177177
csn_t snapshot =execQuery(srcTx,"select dtm_extend('%s')", gtid);
178178
snapshot =execQuery(dstTx,"select dtm_access(%ld, '%s')", snapshot, gtid);
179179

180-
exec(srcTx,"update t set v = v - 1 where u=%d", srcAcc);
180+
exec(srcTx,"savepoint c1");
181+
exec(dstTx,"savepoint c2");
182+
183+
exec(srcTx,"update t set v = v - 1 where u=%d", srcAcc);
181184
exec(dstTx,"update t set v = v + 1 where u=%d", dstAcc);
182185

183186
exec(srcTx,"prepare transaction '%s'", gtid);
@@ -260,7 +263,7 @@ int main (int argc, char* argv[])
260263
return1;
261264
}
262265

263-
if (cfg.startId + cfg.diapason-1> cfg.nAccounts) {
266+
if (cfg.startId + cfg.diapason > cfg.nAccounts) {
264267
printf("startId + diapason should be less that nAccounts. Exiting.\n");
265268
return1;
266269
}
@@ -305,7 +308,7 @@ int main (int argc, char* argv[])
305308
printf(
306309
"{\"update_tps\":%f,\"read_tps\":%f,"
307310
"\"readers\":%d,\"writers\":%d,"
308-
"\"accounts\":%d,\"iterations\":%d,\"hosts\":%d}\n",
311+
"\"accounts\":%d,\"iterations\":%d,\"hosts\":%ld}\n",
309312
(double)(nWrites*USEC)/elapsed,
310313
(double)(nReads*USEC)/elapsed,
311314
cfg.nReaders,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp