Skip to content

Commit 254316f

Browse files
committed
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
1 parent 3ff1588 commit 254316f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/bin/pg_basebackup/receivelog.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,20 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
611611
}
612612
PQclear(res);
613613

614+
/* Complain if we've not reached stop point yet */
615+
if (stream_stop != NULL && !stream_stop(blockpos, timeline, false))
616+
{
617+
fprintf(stderr, _("%s: replication stream was terminated before stop point\n"),
618+
progname);
619+
goto error;
620+
}
621+
614622
if (copybuf != NULL)
615623
PQfreemem(copybuf);
616624
if (walfile != -1 && close(walfile) != 0)
617625
fprintf(stderr, _("%s: could not close file %s: %s\n"),
618626
progname, current_walfile_name, strerror(errno));
627+
walfile = -1;
619628
return true;
620629

621630
error:
@@ -624,5 +633,6 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
624633
if (walfile != -1 && close(walfile) != 0)
625634
fprintf(stderr, _("%s: could not close file %s: %s\n"),
626635
progname, current_walfile_name, strerror(errno));
636+
walfile = -1;
627637
return false;
628638
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy