@@ -187,7 +187,7 @@ int MtmReplicationNodeId;
187
187
int MtmArbiterPort ;
188
188
int MtmConnectAttempts ;
189
189
int MtmConnectTimeout ;
190
- int MtmKeepaliveTimeout ;
190
+ int MtmRaftPollDelay ;
191
191
int MtmReconnectAttempts ;
192
192
int MtmNodeDisableDelay ;
193
193
int MtmTransSpillThreshold ;
@@ -747,7 +747,7 @@ MtmPrePrepareTransaction(MtmCurrentTrans* x)
747
747
/*
748
748
* Check heartbeats
749
749
*/
750
- static void MtmWatchdog ()
750
+ void MtmWatchdog (void )
751
751
{
752
752
int i , n = Mtm -> nAllNodes ;
753
753
timestamp_t now = MtmGetSystemTime ();
@@ -795,33 +795,27 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
795
795
MtmResetTransaction (x );
796
796
} else {
797
797
time_t transTimeout = Max (Mtm2PCMinTimeout , (ts -> csn - ts -> snapshot )* Mtm2PCPrepareRatio /100000 ); /* usec->msec and percents */
798
- time_t timeout = Min (transTimeout , MtmHeartbeatRecvTimeout );
799
- timestamp_t deadline = MtmGetSystemTime () + MSEC_TO_USEC (transTimeout );
800
798
int result = 0 ;
801
799
int nConfigChanges = Mtm -> nConfigChanges ;
802
800
/* wait votes from all nodes */
803
- while (!ts -> votingCompleted ) {
801
+ while (!ts -> votingCompleted && !(result & WL_TIMEOUT ))
802
+ {
804
803
MtmUnlock ();
805
- // MtmWatchdog();
804
+ MtmWatchdog ();
806
805
if (ts -> status == TRANSACTION_STATUS_ABORTED ) {
807
806
elog (WARNING , "Transaction %d(%s) is aborted by watchdog" , x -> xid , x -> gid );
808
807
x -> status = TRANSACTION_STATUS_ABORTED ;
809
808
return ;
810
809
}
811
- result = WaitLatch (& MyProc -> procLatch , WL_LATCH_SET |WL_TIMEOUT , timeout );
810
+ result = WaitLatch (& MyProc -> procLatch , WL_LATCH_SET |WL_TIMEOUT , transTimeout );
812
811
if (result & WL_LATCH_SET ) {
813
812
ResetLatch (& MyProc -> procLatch );
814
- } else if (result & WL_TIMEOUT ) {
815
- if (MtmGetSystemTime () > deadline ) {
816
- MtmLock (LW_SHARED );
817
- break ;
818
- }
819
813
}
820
814
MtmLock (LW_SHARED );
821
815
}
822
816
if (!ts -> votingCompleted ) {
823
817
ts -> status = TRANSACTION_STATUS_ABORTED ;
824
- 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 ));
818
+ elog (WARNING , "Transaction is aborted because of %d msec timeout expiration, prepare time %d msec" , (int )transTimeout , (int )USEC_TO_MSEC (ts -> csn - x -> snapshot ));
825
819
} else if (nConfigChanges != Mtm -> nConfigChanges ) {
826
820
ts -> status = TRANSACTION_STATUS_ABORTED ;
827
821
elog (WARNING , "Transaction is aborted because cluster configuration is changed during commit" );
@@ -1369,8 +1363,7 @@ void MtmOnNodeDisconnect(int nodeId)
1369
1363
BIT_SET (Mtm -> reconnectMask , nodeId - 1 );
1370
1364
RaftableSet (psprintf ("node-mask-%d" , MtmNodeId ), & Mtm -> connectivityMask , sizeof Mtm -> connectivityMask , false);
1371
1365
1372
- /* Wait more than socket KEEPALIVE timeout to let other nodes update their statuses */
1373
- MtmSleep (MtmKeepaliveTimeout );
1366
+ MtmSleep (MtmRaftPollDelay );
1374
1367
1375
1368
if (!MtmRefreshClusterStatus (false)) {
1376
1369
MtmLock (LW_EXCLUSIVE );
@@ -1970,10 +1963,10 @@ _PG_init(void)
1970
1963
);
1971
1964
1972
1965
DefineCustomIntVariable (
1973
- "multimaster.keepalive_timeout " ,
1974
- "Multimaster keepalive interval for sockets " ,
1966
+ "multimaster.raft_poll_delay " ,
1967
+ "Multimaster delay of polling cluster state from Raftable after updating local node status " ,
1975
1968
"Timeout in microseconds before polling state of nodes" ,
1976
- & MtmKeepaliveTimeout ,
1969
+ & MtmRaftPollDelay ,
1977
1970
1000000 ,
1978
1971
1 ,
1979
1972
INT_MAX ,
0 commit comments