mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
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
This commit is contained in:
parent
3ff15883b1
commit
254316f5a2
@ -611,11 +611,20 @@ ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
|
|||||||
}
|
}
|
||||||
PQclear(res);
|
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)
|
if (copybuf != NULL)
|
||||||
PQfreemem(copybuf);
|
PQfreemem(copybuf);
|
||||||
if (walfile != -1 && close(walfile) != 0)
|
if (walfile != -1 && close(walfile) != 0)
|
||||||
fprintf(stderr, _("%s: could not close file %s: %s\n"),
|
fprintf(stderr, _("%s: could not close file %s: %s\n"),
|
||||||
progname, current_walfile_name, strerror(errno));
|
progname, current_walfile_name, strerror(errno));
|
||||||
|
walfile = -1;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -624,5 +633,6 @@ error:
|
|||||||
if (walfile != -1 && close(walfile) != 0)
|
if (walfile != -1 && close(walfile) != 0)
|
||||||
fprintf(stderr, _("%s: could not close file %s: %s\n"),
|
fprintf(stderr, _("%s: could not close file %s: %s\n"),
|
||||||
progname, current_walfile_name, strerror(errno));
|
progname, current_walfile_name, strerror(errno));
|
||||||
|
walfile = -1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user