From c6931b512ca37991a068a632d00fe0e4a6df46bb Mon Sep 17 00:00:00 2001 From: Kyotaro Horiguchi Date: Mon, 28 Aug 2017 18:46:49 +0900 Subject: [PATCH 2/2] Debug assistant code. This patch reliably reproduces the problematic situation. --- src/backend/replication/walreceiver.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index ea9d21a..9dbf9e1 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -986,6 +986,29 @@ XLogWalRcvWrite(char *buf, Size nbytes, XLogRecPtr recptr) recvFile = XLogFileInit(recvSegNo, &use_existent, true); recvFileTLI = ThisTimeLineID; recvOff = 0; + + if ((recptr & 0xffffffL) == 0) + { + XLogPageHeader ph = (XLogPageHeader) buf; + Assert(nbytes >= sizeof(SizeOfXLogShortPHD)); + + elog(LOG, "############# CHECK AT %lX : %d", + recptr, (ph->xlp_info & XLP_FIRST_IS_CONTRECORD) != 0); + if (ph->xlp_info & XLP_FIRST_IS_CONTRECORD) + { + struct stat sbuf; + if (stat("/tmp/hoge", &sbuf) == 0) + { + elog(LOG, "#################### STOP THE SERVER"); + system("pg_ctl stop -m f -W"); + while (1) + { + ProcessWalRcvInterrupts(); + sleep(1); + } + } + } + } } /* Calculate the start offset of the received logs */ -- 2.9.2