aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2012-08-06 13:53:46 +0200
committerMagnus Hagander <magnus@hagander.net>2012-08-06 13:55:52 +0200
commit0b4660b539821ccdef99e43e79deb023a68db34e (patch)
tree18cd94cca2ded28c6dc81dd43fe20fe40a7f4612 /src
parentd9c77e249339ec3a49731be55ff22bbdd5a1fcf0 (diff)
downloadpostgresql-0b4660b539821ccdef99e43e79deb023a68db34e.tar.gz
postgresql-0b4660b539821ccdef99e43e79deb023a68db34e.zip
Complain with proper error message if streaming stops prematurely
In particular, with a controlled shutdown of the master, pg_basebackup with streaming log could terminate without an error message, even though the backup is not consistent. In passing, fix a few cases where walfile wasn't properly set to -1 after closing. Fujii Masao
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_basebackup/receivelog.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c
index 3b464123b34..9de0eb6275c 100644
--- a/src/bin/pg_basebackup/receivelog.c
+++ b/src/bin/pg_basebackup/receivelog.c
@@ -611,11 +611,20 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
}
PQclear(res);
+ /* Complain if we've not reached stop point yet */
+ if (stream_stop != NULL && !stream_stop(blockpos, timeline, false))
+ {
+ fprintf(stderr, _("%s: replication stream was terminated before stop point\n"),
+ progname);
+ goto error;
+ }
+
if (copybuf != NULL)
PQfreemem(copybuf);
if (walfile != -1 && close(walfile) != 0)
fprintf(stderr, _("%s: could not close file %s: %s\n"),
progname, current_walfile_name, strerror(errno));
+ walfile = -1;
return true;
error:
@@ -624,5 +633,6 @@ error:
if (walfile != -1 && close(walfile) != 0)
fprintf(stderr, _("%s: could not close file %s: %s\n"),
progname, current_walfile_name, strerror(errno));
+ walfile = -1;
return false;
}