Hello,I stumbled on a windows-only bug in pg_basebackup which I've reported as #16032 (https://www.postgresql.org/message-id/16032-4ba56823a2b2805f%40postgresql.org).
I'm pretty sure I've fixed it in the attached patch. Many Thanks, Rob
From 148d525c0d30af35abba1b8c5bbe07e4e72ecfec Mon Sep 17 00:00:00 2001 From: Rob Emery <mints...@users.noreply.github.com> Date: Tue, 1 Oct 2019 23:51:52 +0100 Subject: [PATCH] Fix bug16032; under windows when the backup is aborted or fails, pg_basebackup is unable to cleanup the backup as the filehandles haven't been released --- src/bin/pg_basebackup/pg_basebackup.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index aa68f59965..b6d68e0256 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -1098,6 +1098,17 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum) { fprintf(stderr, _("%s: could not get COPY data stream: %s"), progname, PQerrorMessage(conn)); + if (strcmp(basedir, "-") != 0) + { + /* + * File handles could already be closed so we don't care about the result + */ +#ifdef HAVE_LIBZ + gzclose(ztarfile); +#else + fclose(tarfile); +#endif + } disconnect_and_exit(1); } @@ -1179,6 +1190,17 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum) { fprintf(stderr, _("%s: could not read COPY data: %s"), progname, PQerrorMessage(conn)); + if (strcmp(basedir, "-") != 0) + { + /* + * File handles could already be closed so we don't care about the result + */ +#ifdef HAVE_LIBZ + gzclose(ztarfile); +#else + fclose(tarfile); +#endif + } disconnect_and_exit(1); } -- 2.11.0