master and slave snyc time

Code Source From: Self Code
Description:  【Optional】
Jira:  #【Optional】
市场项目编号(名称):【Optional】
This commit is contained in:
shenzhengntu 2023-03-31 17:03:38 +08:00
parent 9edccb4067
commit ae812aee1e
2 changed files with 12 additions and 3 deletions

View File

@ -95,7 +95,8 @@ bool hot_standby_feedback;
static WalReceiverConn *wrconn = NULL;
WalReceiverFunctionsType *WalReceiverFunctions = NULL;
#define NAPTIME_PER_CYCLE 100 /* max sleep time between cycles (100ms) */
//#define NAPTIME_PER_CYCLE 100 /* max sleep time between cycles (100ms) */
#define NAPTIME_PER_CYCLE 10 /* max sleep time between cycles (10ms) */
/*
* These variables are used similarly to openLogFile/SegNo,
@ -1124,6 +1125,11 @@ XLogWalRcvSendReply(bool force, bool requestReply)
writePtr = LogstreamResult.Write;
flushPtr = LogstreamResult.Flush;
applyPtr = GetXLogReplayRecPtr(NULL);
#ifndef PG_NOREPLAY
if (push_standby == true) {
applyPtr = GetXLogPushToDisk();
}
#endif
resetStringInfo(&reply_message);
pq_sendbyte(&reply_message, 'r');

View File

@ -1300,7 +1300,7 @@ WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid,
break;
sleeptime = WalSndComputeSleeptime(GetCurrentTimestamp());
sleeptime = 10; //10ms
/* Sleep until something happens or we time out */
WalSndWait(WL_SOCKET_WRITEABLE | WL_SOCKET_READABLE, sleeptime,
WAIT_EVENT_WAL_SENDER_WRITE_DATA);
@ -2374,7 +2374,7 @@ WalSndLoop(WalSndSendDataCallback send_data)
* of reaching wal_sender_timeout before sending a keepalive.
*/
sleeptime = WalSndComputeSleeptime(GetCurrentTimestamp());
sleeptime = 10; //10ms
if (pq_is_send_pending())
wakeEvents |= WL_SOCKET_WRITEABLE;
@ -3533,6 +3533,9 @@ WalSndKeepaliveIfNecessary(void)
/* Try to flush pending output to the client */
if (pq_flush_if_writable() != 0)
WalSndShutdown();
} else {
WalSndKeepalive(true);
pg_usleep(10000);
}
}