Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 02789a0

Browse files
knizhnikkelvich
authored andcommitted
Accept abort transaction at prepare stage
1 parent de99b01 commit 02789a0

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

arbiter.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -776,17 +776,23 @@ static void MtmTransReceiver(Datum arg)
776776
}
777777
break;
778778
case MSG_PREPARED:
779-
Assert(ts->status == TRANSACTION_STATUS_IN_PROGRESS);
780-
Assert(ts->nVotes < Mtm->nLiveNodes);
781-
if (msg->csn > ts->csn) {
782-
ts->csn = msg->csn;
783-
MtmSyncClock(ts->csn);
784-
}
785-
if (++ts->nVotes == Mtm->nLiveNodes) {
786-
ts->csn = MtmAssignCSN();
787-
ts->status = TRANSACTION_STATUS_UNKNOWN;
788-
MtmWakeUpBackend(ts);
789-
}
779+
if (ts->status != TRANSACTION_STATUS_ABORTED) {
780+
Assert(ts->status == TRANSACTION_STATUS_IN_PROGRESS);
781+
Assert(ts->nVotes < Mtm->nLiveNodes);
782+
if (msg->csn > ts->csn) {
783+
ts->csn = msg->csn;
784+
MtmSyncClock(ts->csn);
785+
}
786+
if (++ts->nVotes == Mtm->nLiveNodes) {
787+
ts->csn = MtmAssignCSN();
788+
ts->status = TRANSACTION_STATUS_UNKNOWN;
789+
MtmWakeUpBackend(ts);
790+
}
791+
} else {
792+
if (++ts->nVotes == Mtm->nLiveNodes) {
793+
MtmWakeUpBackend(ts);
794+
}
795+
}
790796
break;
791797
default:
792798
Assert(false);

multimaster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
794794
MtmResetTransaction(x);
795795
} else {
796796
time_t transTimeout = Max(Mtm2PCMinTimeout, (ts->csn - ts->snapshot)*Mtm2PCPrepareRatio/100000); /* usec->msec and percents */
797-
time_t timeout = transTimeout < MtmHeartbeatRecvTimeout ? transTimeout : MtmHeartbeatRecvTimeout;
797+
time_t timeout = Min(transTimeout, MtmHeartbeatRecvTimeout);
798798
timestamp_t deadline = MtmGetSystemTime() + MSEC_TO_USEC(transTimeout);
799799
int result = 0;
800800
int nConfigChanges = Mtm->nConfigChanges;

0 commit comments

Comments
 (0)