0002-Accept-and-ignore-keepalive-messages-in-pg_basebacku.patch
text/x-patch
Filename: 0002-Accept-and-ignore-keepalive-messages-in-pg_basebacku.patch
Type: text/x-patch
Part: 1
Message:
Re: streaming header too small
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: format-patch
Series: patch 0002
Subject: Accept (and ignore) keepalive messages in pg_basebackup
| File | + | − |
|---|---|---|
| src/bin/pg_basebackup/receivelog.c | 17 | 1 |
From 0c590630575014c1bc5a2ed700b802000d6a24ac Mon Sep 17 00:00:00 2001
From: Magnus Hagander <magnus@hagander.net>
Date: Mon, 9 Jan 2012 11:57:56 +0100
Subject: [PATCH 2/2] Accept (and ignore) keepalive messages in pg_basebackup
---
src/bin/pg_basebackup/receivelog.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c
index d76eed6..c5579ee 100644
--- a/src/bin/pg_basebackup/receivelog.c
+++ b/src/bin/pg_basebackup/receivelog.c
@@ -35,6 +35,7 @@
/* Size of the streaming replication protocol header */
#define STREAMING_HEADER_SIZE (1+8+8+8)
+#define STREAMING_KEEPALIVE_SIZE (1+8+8)
const XLogRecPtr InvalidXLogRecPtr = {0, 0};
@@ -374,7 +375,22 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline, char *sysi
progname, PQerrorMessage(conn));
return false;
}
- if (copybuf[0] != 'w')
+ if (copybuf[0] == 'k')
+ {
+ /*
+ * keepalive message, sent in 9.2 and newer. We just ignore
+ * this message completely, but need to forward past it
+ * in our reading.
+ */
+ if (r != STREAMING_KEEPALIVE_SIZE)
+ {
+ fprintf(stderr, _("%s: keepalive message is incorrect size: %i\n"),
+ progname, r);
+ return false;
+ }
+ continue;
+ }
+ else if (copybuf[0] != 'w')
{
fprintf(stderr, _("%s: unrecognized streaming header: \"%c\"\n"),
progname, copybuf[0]);
--
1.7.5.4