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

Commite2eaa0c

Browse files
knizhnikkelvich
authored andcommitted
Reduce WaitLatch timeout
1 parentce87760 commite2eaa0c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

‎multimaster.c

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

738738
if (Mtm->disabledNodeMask!=0) {
739-
MtmRefreshClusterStatus(true);
739+
timestamp_tnow=MtmGetSystemTime();
740+
if (Mtm->lastClusterStatusUpdate+MSEC_TO_USEC(MtmRaftPollDelay)<now) {
741+
Mtm->lastClusterStatusUpdate=now;
742+
MtmRefreshClusterStatus(true);
743+
}
740744
if (!IsBackgroundWorker&&Mtm->status!=MTM_ONLINE) {
741-
/* Do not take inaccoutn bg-workers which are performing recovery */
745+
/* Do not take inaccount bg-workers which are performing recovery */
742746
elog(ERROR,"Abort current transaction because this cluster node is in %s status",MtmNodeStatusMnem[Mtm->status]);
743747
}
744748
}
@@ -834,8 +838,10 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
834838
time_ttransTimeout=Max(Mtm2PCMinTimeout, (ts->csn-ts->snapshot)*Mtm2PCPrepareRatio/100000);/* usec->msec and percents */
835839
intresult=0;
836840
intnConfigChanges=Mtm->nConfigChanges;
841+
842+
timestamp_tstart=MtmGetSystemTime();
837843
/* wait votes from all nodes */
838-
while (!ts->votingCompleted&&!(result&WL_TIMEOUT))
844+
while (!ts->votingCompleted&&start+transTimeout >=MtmGetSystemTime())
839845
{
840846
MtmUnlock();
841847
MtmWatchdog();
@@ -844,7 +850,7 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
844850
x->status=TRANSACTION_STATUS_ABORTED;
845851
return;
846852
}
847-
result=WaitLatch(&MyProc->procLatch,WL_LATCH_SET|WL_TIMEOUT,transTimeout);
853+
result=WaitLatch(&MyProc->procLatch,WL_LATCH_SET|WL_TIMEOUT,MtmHeartbeatRecvTimeout);
848854
if (result&WL_LATCH_SET) {
849855
ResetLatch(&MyProc->procLatch);
850856
}
@@ -1568,6 +1574,7 @@ static void MtmInitialize()
15681574
Mtm->recoverySlot=0;
15691575
Mtm->locks=GetNamedLWLockTranche(MULTIMASTER_NAME);
15701576
Mtm->csn=MtmGetCurrentTime();
1577+
Mtm->lastClusterStatusUpdate=MtmGetSystemTime();
15711578
Mtm->lastCsn=INVALID_CSN;
15721579
Mtm->oldestXid=FirstNormalTransactionId;
15731580
Mtm->nLiveNodes=MtmNodes;

‎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
uint64transCount;/* Counter of transactions perfromed by this node */
191191
uint64gcCount;/* Number of global transactions performed since last GC */
192-
BgwPoolpool;/* Pool of background workers for applying logical replication patches */
192+
timestamp_tlastClusterStatusUpdate;/* Time of last update of cluster status */
193+
BgwPoolpool;/* Pool of background workers for applying logical replication patches */
193194
MtmNodeInfonodes[1];/* [Mtm->nAllNodes]: per-node data */
194195
}MtmState;
195196

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp