repl_border_bug_test.patch

text/x-patch

Filename: repl_border_bug_test.patch
Type: text/x-patch
Part: 0
Message: Re: [BUGS] Bug in Physical Replication Slots (at least 9.5)?

Patch

Format: unified
File+
src/backend/replication/walreceiver.c 23 0
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 771ac30..f1de180 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 */