set nonblocking to send walsender timeout messgae to frontend
This commit is contained in:
@ -3639,7 +3639,15 @@ static void send_message_to_frontend(ErrorData* edata)
|
||||
!t_thrd.log_cxt.flush_message_immediately)
|
||||
return;
|
||||
|
||||
pq_flush();
|
||||
/*
|
||||
* If it is WalSender's timeout message, choose pq_flush_if_writable()
|
||||
* to avoid blokcing in send() if the send buffer of the socket is full.
|
||||
*/
|
||||
if (AM_WAL_NORMAL_SENDER && t_thrd.walsender_cxt.isWalSndSendTimeoutMessage) {
|
||||
pq_flush_if_writable();
|
||||
} else {
|
||||
pq_flush();
|
||||
}
|
||||
|
||||
if (edata->elevel == FATAL)
|
||||
t_thrd.log_cxt.flush_message_immediately = true;
|
||||
|
1
src/gausskernel/process/threadpool/knl_thread.cpp
Executable file → Normal file
1
src/gausskernel/process/threadpool/knl_thread.cpp
Executable file → Normal file
@ -1364,6 +1364,7 @@ static void knl_t_walsender_init(knl_t_walsender_context* walsender_cxt)
|
||||
walsender_cxt->remotePort = 0;
|
||||
walsender_cxt->walSndCaughtUp = false;
|
||||
walsender_cxt->last_check_timeout_timestamp = 0;
|
||||
walsender_cxt->isWalSndSendTimeoutMessage = false;
|
||||
walsender_cxt->advancePrimaryConn = NULL;
|
||||
|
||||
walsender_cxt->ep_fd = -1;
|
||||
|
@ -3588,6 +3588,8 @@ static void WalSndCheckTimeOut(TimestampTz now)
|
||||
* standby.
|
||||
*/
|
||||
if (log_min_messages <= ERROR || client_min_messages <= ERROR) {
|
||||
t_thrd.walsender_cxt.isWalSndSendTimeoutMessage = true;
|
||||
|
||||
WalReplicationTimestampInfo timeStampInfo;
|
||||
WalReplicationTimestampToString(&timeStampInfo, now, timeout, *last_reply_time, heartbeat);
|
||||
ereport(ERROR, (errmsg("terminating Walsender process due to replication timeout."),
|
||||
|
3
src/include/knl/knl_thread.h
Executable file → Normal file
3
src/include/knl/knl_thread.h
Executable file → Normal file
@ -2283,7 +2283,8 @@ typedef struct knl_t_walsender_context {
|
||||
struct pg_conn* advancePrimaryConn;
|
||||
/* Timestamp of the last check-timeout time in WalSndCheckTimeOut. */
|
||||
TimestampTz last_check_timeout_timestamp;
|
||||
|
||||
/* flag set in WalSndCheckTimeout */
|
||||
bool isWalSndSendTimeoutMessage;
|
||||
|
||||
int datafd;
|
||||
int ep_fd;
|
||||
|
Reference in New Issue
Block a user