write_finalize_tot_len.diff

text/x-patch

Filename: write_finalize_tot_len.diff
Type: text/x-patch
Part: 0
Message: Re: BUG #17928: Standby fails to decode WAL on termination of primary

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/replication/walreceiver.c 9 0
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index feff709435..a570d56ada 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -989,6 +989,15 @@ XLogWalRcvFlush(bool dying, TimeLineID tli)
 {
 	Assert(tli != 0);
 
+	if (dying)
+	{
+		int buflen = sizeof(uint32);
+		char buf[sizeof(uint32)];
+		
+		memset(buf, 0, buflen);
+		XLogWalRcvWrite(buf, buflen, LogstreamResult.Write, tli);
+	}
+	
 	if (LogstreamResult.Flush < LogstreamResult.Write)
 	{
 		WalRcvData *walrcv = WalRcv;