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

Commit3a08736

Browse files
committed
WAL receiver shouldn't try to send a reply when dying.
Per report from, and discussion with, Fujii Masao.
1 parent6e02755 commit3a08736

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

‎src/backend/replication/walreceiver.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void DisableWalRcvImmediateExit(void);
118118
staticvoidWalRcvDie(intcode,Datumarg);
119119
staticvoidXLogWalRcvProcessMsg(unsignedchartype,char*buf,Sizelen);
120120
staticvoidXLogWalRcvWrite(char*buf,Sizenbytes,XLogRecPtrrecptr);
121-
staticvoidXLogWalRcvFlush(void);
121+
staticvoidXLogWalRcvFlush(booldying);
122122
staticvoidXLogWalRcvSendReply(void);
123123

124124
/* Signal handlers */
@@ -319,7 +319,7 @@ WalReceiverMain(void)
319319
* If we've written some records, flush them to disk and let the
320320
* startup process know about them.
321321
*/
322-
XLogWalRcvFlush();
322+
XLogWalRcvFlush(false);
323323
}
324324
else
325325
{
@@ -342,7 +342,7 @@ WalRcvDie(int code, Datum arg)
342342
volatileWalRcvData*walrcv=WalRcv;
343343

344344
/* Ensure that all WAL records received are flushed to disk */
345-
XLogWalRcvFlush();
345+
XLogWalRcvFlush(true);
346346

347347
SpinLockAcquire(&walrcv->mutex);
348348
Assert(walrcv->walRcvState==WALRCV_RUNNING||
@@ -461,7 +461,7 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr)
461461
*/
462462
if (recvFile >=0)
463463
{
464-
XLogWalRcvFlush();
464+
XLogWalRcvFlush(false);
465465

466466
/*
467467
* XLOG segment files will be re-read by recovery in startup
@@ -531,9 +531,14 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr)
531531
}
532532
}
533533

534-
/* Flush the log to disk */
534+
/*
535+
* Flush the log to disk.
536+
*
537+
* If we're in the midst of dying, it's unwise to do anything that might throw
538+
* an error, so we skip sending a reply in that case.
539+
*/
535540
staticvoid
536-
XLogWalRcvFlush(void)
541+
XLogWalRcvFlush(booldying)
537542
{
538543
if (XLByteLT(LogstreamResult.Flush,LogstreamResult.Write))
539544
{
@@ -565,7 +570,8 @@ XLogWalRcvFlush(void)
565570
}
566571

567572
/* Also let the master know that we made some progress */
568-
XLogWalRcvSendReply();
573+
if (!dying)
574+
XLogWalRcvSendReply();
569575
}
570576
}
571577

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp