static void WalRcvDie(int code, Datum arg);
static void XLogWalRcvProcessMsg(unsigned char type, char *buf, Size len);
static void XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr);
-static void XLogWalRcvFlush(void);
+static void XLogWalRcvFlush(bool dying);
static void XLogWalRcvSendReply(void);
/* Signal handlers */
* If we've written some records, flush them to disk and let the
* startup process know about them.
*/
- XLogWalRcvFlush();
+ XLogWalRcvFlush(false);
}
else
{
volatile WalRcvData *walrcv = WalRcv;
/* Ensure that all WAL records received are flushed to disk */
- XLogWalRcvFlush();
+ XLogWalRcvFlush(true);
SpinLockAcquire(&walrcv->mutex);
Assert(walrcv->walRcvState == WALRCV_RUNNING ||
*/
if (recvFile >= 0)
{
- XLogWalRcvFlush();
+ XLogWalRcvFlush(false);
/*
* XLOG segment files will be re-read by recovery in startup
}
}
-/* Flush the log to disk */
+/*
+ * Flush the log to disk.
+ *
+ * If we're in the midst of dying, it's unwise to do anything that might throw
+ * an error, so we skip sending a reply in that case.
+ */
static void
-XLogWalRcvFlush(void)
+XLogWalRcvFlush(bool dying)
{
if (XLByteLT(LogstreamResult.Flush, LogstreamResult.Write))
{
}
/* Also let the master know that we made some progress */
- XLogWalRcvSendReply();
+ if (!dying)
+ XLogWalRcvSendReply();
}
}