From 5f0ba4abb33640205f38e5bee1e981da25175acf Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 6 Feb 2015 11:18:14 +0200 Subject: [PATCH] Report WAL flush, not insert, position in replication IDENTIFY_SYSTEM When beginning streaming replication, the client usually issues the IDENTIFY_SYSTEM command, which used to return the current WAL insert position. That's not suitable for the intended purpose of that field, however. pg_receivexlog uses it to start replication from the reported point, but if it hasn't been flushed to disk yet, it will fail. Change IDENTIFY_SYSTEM to report the flush position instead. Backpatch to 9.1 and above. 9.0 doesn't report any WAL position. --- doc/src/sgml/protocol.sgml | 2 +- src/backend/replication/walsender.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml index 1457ae84523..428d22040da 100644 --- a/doc/src/sgml/protocol.sgml +++ b/doc/src/sgml/protocol.sgml @@ -1350,7 +1350,7 @@ The commands accepted in walsender mode are: - Current xlog write location. Useful to get a known location in the + Current xlog flush location. Useful to get a known location in the transaction log where streaming can start. diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 442b13a1123..68b4f4f0e4b 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -259,7 +259,7 @@ IdentifySystem(void) logptr = GetStandbyFlushRecPtr(); } else - logptr = GetInsertRecPtr(); + logptr = GetFlushRecPtr(); snprintf(tli, sizeof(tli), "%u", ThisTimeLineID);