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

Commit 9d5096e

Browse files
committed
Merge branch 'master' of github.com:postgrespro/postgres_cluster
2 parents ef7c139 + 8e729f5 commit 9d5096e

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

contrib/mmts/multimaster.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,13 @@ MtmPrePrepareTransaction(MtmCurrentTrans* x)
737737
Assert(TransactionIdIsValid(x->xid));
738738

739739
if (Mtm->disabledNodeMask != 0) {
740-
MtmRefreshClusterStatus(true);
740+
timestamp_t now = MtmGetSystemTime();
741+
if (Mtm->lastClusterStatusUpdate + MSEC_TO_USEC(MtmRaftPollDelay) < now) {
742+
Mtm->lastClusterStatusUpdate = now;
743+
MtmRefreshClusterStatus(true);
744+
}
741745
if (!IsBackgroundWorker && Mtm->status != MTM_ONLINE) {
742-
/* Do not take in accoutn bg-workers which are performing recovery */
746+
/* Do not take in account bg-workers which are performing recovery */
743747
elog(ERROR, "Abort current transaction because this cluster node is in %s status", MtmNodeStatusMnem[Mtm->status]);
744748
}
745749
}
@@ -835,8 +839,10 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
835839
time_t transTimeout = Max(Mtm2PCMinTimeout, (ts->csn - ts->snapshot)*Mtm2PCPrepareRatio/100000); /* usec->msec and percents */
836840
int result = 0;
837841
int nConfigChanges = Mtm->nConfigChanges;
842+
843+
timestamp_t start = MtmGetSystemTime();
838844
/* wait votes from all nodes */
839-
while (!ts->votingCompleted && !(result & WL_TIMEOUT))
845+
while (!ts->votingCompleted && start + transTimeout >= MtmGetSystemTime())
840846
{
841847
MtmUnlock();
842848
MtmWatchdog();
@@ -845,7 +851,7 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
845851
x->status = TRANSACTION_STATUS_ABORTED;
846852
return;
847853
}
848-
result = WaitLatch(&MyProc->procLatch, WL_LATCH_SET|WL_TIMEOUT, transTimeout);
854+
result = WaitLatch(&MyProc->procLatch, WL_LATCH_SET|WL_TIMEOUT, MtmHeartbeatRecvTimeout);
849855
if (result & WL_LATCH_SET) {
850856
ResetLatch(&MyProc->procLatch);
851857
}
@@ -1569,6 +1575,7 @@ static void MtmInitialize()
15691575
Mtm->recoverySlot = 0;
15701576
Mtm->locks = GetNamedLWLockTranche(MULTIMASTER_NAME);
15711577
Mtm->csn = MtmGetCurrentTime();
1578+
Mtm->lastClusterStatusUpdate = MtmGetSystemTime();
15721579
Mtm->lastCsn = INVALID_CSN;
15731580
Mtm->oldestXid = FirstNormalTransactionId;
15741581
Mtm->nLiveNodes = MtmNodes;

contrib/mmts/multimaster.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ typedef struct
189189
This list is expected to be in CSN ascending order, by strict order may be violated */
190190
uint64 transCount; /* Counter of transactions perfromed by this node */
191191
uint64 gcCount; /* Number of global transactions performed since last GC */
192-
BgwPool pool; /* Pool of background workers for applying logical replication patches */
192+
timestamp_t lastClusterStatusUpdate;/* Time of last update of cluster status */
193+
BgwPool pool; /* Pool of background workers for applying logical replication patches */
193194
MtmNodeInfo nodes[1]; /* [Mtm->nAllNodes]: per-node data */
194195
} MtmState;
195196

0 commit comments

Comments
 (0)