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