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

Commitbf168d6

Browse files
knizhnikkelvich
authored andcommitted
Abort transaction ni case of cluster configuration change
1 parent2af3235 commitbf168d6

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

‎multimaster.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ void MtmSleep(timestamp_t interval)
273273
{
274274
structtimespects;
275275
structtimespecrem;
276-
ts.tv_sec=interval/1000000;
277-
ts.tv_nsec=interval%1000000*1000;
276+
ts.tv_sec=interval/USECS_PER_SEC;
277+
ts.tv_nsec=interval%USECS_PER_SEC*1000;
278278

279279
while (nanosleep(&ts,&rem)<0) {
280280
Assert(errno==EINTR);
@@ -751,16 +751,20 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
751751
}else {
752752
time_ttimeout=Max(Mtm2PCMinTimeout, (ts->csn-ts->snapshot)*Mtm2PCPrepareRatio/100000);/* usec->msec and percents */
753753
intresult=0;
754+
intnConfigChanges=Mtm->nConfigChanges;
754755
/* wait votes from all nodes */
755756
while (!ts->votingCompleted&& !(result&WL_TIMEOUT)) {
756757
MtmUnlock();
757758
result=WaitLatch(&MyProc->procLatch,WL_LATCH_SET|WL_TIMEOUT,timeout);
758759
ResetLatch(&MyProc->procLatch);
759760
MtmLock(LW_SHARED);
760761
}
761-
if (!ts->votingCompleted) {
762+
if (!ts->votingCompleted) {
762763
ts->status=TRANSACTION_STATUS_ABORTED;
763-
elog(WARNING,"Transaction is aborted because of %d msec timeout expiration, prepare time %d msec", (int)timeout, (int)((ts->csn-x->snapshot)/1000));
764+
elog(WARNING,"Transaction is aborted because of %d msec timeout expiration, prepare time %d msec", (int)timeout, (int)USEC_TO_MSEC(ts->csn-x->snapshot));
765+
}elseif (nConfigChanges!=Mtm->nConfigChanges) {
766+
ts->status=TRANSACTION_STATUS_ABORTED;
767+
elog(WARNING,"Transaction is aborted because cluster configuration is changed during commit");
764768
}
765769
x->status=ts->status;
766770
MTM_LOG3("%d: Result of vote: %d",MyProcPid,ts->status);
@@ -1088,6 +1092,7 @@ bool MtmRecoveryCaughtUp(int nodeId, XLogRecPtr slotLSN)
10881092
BIT_CLEAR(Mtm->disabledNodeMask,nodeId-1);
10891093
Mtm->nodes[nodeId-1].lastStatusChangeTime=MtmGetSystemTime();
10901094
Mtm->nLiveNodes+=1;
1095+
Mtm->nConfigChanges+=1;
10911096
caughtUp= true;
10921097
}elseif (!BIT_CHECK(Mtm->nodeLockerMask,nodeId-1)
10931098
&&slotLSN+MtmMinRecoveryLag>walLSN)
@@ -1262,6 +1267,7 @@ bool MtmRefreshClusterStatus(bool nowait)
12621267

12631268
voidMtmCheckQuorum(void)
12641269
{
1270+
Mtm->nConfigChanges+=1;
12651271
if (Mtm->nLiveNodes<Mtm->nAllNodes/2+1) {
12661272
if (Mtm->status==MTM_ONLINE) {/* out of quorum */
12671273
elog(WARNING,"Node is in minority: disabled mask %lx", (long)Mtm->disabledNodeMask);
@@ -1459,6 +1465,7 @@ static void MtmInitialize()
14591465
Mtm->nReceivers=0;
14601466
Mtm->timeShift=0;
14611467
Mtm->transCount=0;
1468+
Mtm->nConfigChanges=0;
14621469
Mtm->localTablesHashLoaded= false;
14631470
for (i=0;i<MtmNodes;i++) {
14641471
Mtm->nodes[i].oldestSnapshot=0;

‎multimaster.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ typedef struct
169169
intnReceivers;/* Number of initialized logical receivers (used to determine moment when Mtm intialization is completed */
170170
intnLockers;/* Number of lockers */
171171
intnActiveTransactions;/* Nunmber of active 2PC transactions */
172-
longtimeShift;/* Local time correction */
172+
intnConfigChanges;/* Number of cluster configuration changes */
173+
int64timeShift;/* Local time correction */
173174
csn_tcsn;/* Last obtained CSN: used to provide unique acending CSNs based on system time */
174175
MtmTransState*votingTransactions;/* L1-list of replicated transactions sendings notifications to coordinator.
175176
This list is used to pass information to mtm-sender BGW */

‎tests/dtmacid.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ void* reader(void* arg)
144144
}
145145
}
146146
}
147-
t.transactions +=2;
148147
t.selects +=2;
149148
txn1.commit();
150149
txn2.commit();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp