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

Commitfcd6771

Browse files
knizhnikkelvich
authored andcommitted
Handle distributed readonly transactions committed without setting status in CLOG
1 parentcdead0f commitfcd6771

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

‎contrib/multimaster/multimaster.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ static int MMWorkers;
141141
staticchar*DtmHost;
142142
staticintDtmPort;
143143
staticintDtmBufferSize;
144+
staticboolDtmVoted;
144145

145146
staticExecutorFinish_hook_typePreviousExecutorFinishHook=NULL;
146147
staticvoidMMExecutorFinish(QueryDesc*queryDesc);
@@ -645,6 +646,7 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
645646
{
646647
if (TransactionIdIsValid(DtmNextXid))
647648
{
649+
DtmVoted= true;
648650
if (status==TRANSACTION_STATUS_ABORTED|| !MMIsDistributedTrans)
649651
{
650652
PgTransactionIdSetTreeStatus(xid,nsubxids,subxids,status,lsn);
@@ -774,6 +776,9 @@ DtmXactCallback(XactEvent event, void *arg)
774776
caseXACT_EVENT_ABORT:
775777
if (TransactionIdIsValid(DtmNextXid))
776778
{
779+
if (!DtmVoted) {
780+
DtmGlobalSetTransStatus(DtmNextXid,TRANSACTION_STATUS_ABORTED, false);
781+
}
777782
if (event==XACT_EVENT_COMMIT)
778783
{
779784
/*
@@ -784,6 +789,7 @@ DtmXactCallback(XactEvent event, void *arg)
784789
hash_search(xid_in_doubt,&DtmNextXid,HASH_REMOVE,NULL);
785790
LWLockRelease(dtm->hashLock);
786791
}
792+
#if0/* should be handled now using DtmVoted flag */
787793
else
788794
{
789795
/*
@@ -796,6 +802,7 @@ DtmXactCallback(XactEvent event, void *arg)
796802
DtmGlobalSetTransStatus(DtmNextXid,TRANSACTION_STATUS_ABORTED, false);
797803
}
798804
}
805+
#endif
799806
DtmNextXid=InvalidTransactionId;
800807
DtmLastSnapshot=NULL;
801808
}
@@ -1008,6 +1015,7 @@ void MMBeginTransaction(void)
10081015
elog(ERROR,"Arbiter was not able to assign XID");
10091016
XTM_INFO("%d: Start global transaction %d, dtm->minXid=%d\n",getpid(),DtmNextXid,dtm->minXid);
10101017

1018+
DtmVoted= false;
10111019
DtmHasGlobalSnapshot= true;
10121020
DtmLastSnapshot=NULL;
10131021
MMIsDistributedTrans= false;
@@ -1020,6 +1028,7 @@ void MMJoinTransaction(TransactionId xid)
10201028
DtmNextXid=xid;
10211029
if (!TransactionIdIsValid(DtmNextXid))
10221030
elog(ERROR,"Arbiter was not able to assign XID");
1031+
DtmVoted= false;
10231032

10241033
DtmGlobalGetSnapshot(DtmNextXid,&DtmSnapshot,&dtm->minXid);
10251034
XTM_INFO("%d: Join global transaction %d, dtm->minXid=%d\n",getpid(),DtmNextXid,dtm->minXid);

‎contrib/multimaster/tests/mm.pgb‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
\setrandom id1 1 100000
2+
\setrandom id2 1 100000
3+
begin;
4+
--select v from t where u=:id;
5+
update t set v = v - 1 where u=:id1;
6+
update t set v = v + 1 where u=:id2;
7+
commit;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pgbench -M prepared -f mm.pgb -T 15 -P 1 -c 50 -j 16 -r postgres

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp