Fix for Bug #16032
Started by Robover 6 years ago2 messages
Hello,
I stumbled on a windows-only bug in pg_basebackup which I've reported as
#16032
(/messages/by-id/16032-4ba56823a2b2805f@postgresql.org).
I'm pretty sure I've fixed it in the attached patch.
Many Thanks,
Rob
Attachments:
0001-Fix-bug16032-under-windows-when-the-backup-is-aborte.patchtext/x-diff; name=0001-Fix-bug16032-under-windows-when-the-backup-is-aborte.patchDownload
From 148d525c0d30af35abba1b8c5bbe07e4e72ecfec Mon Sep 17 00:00:00 2001
From: Rob Emery <mintsoft@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
Re: Fix for Bug #16032
Hi Rob,
On Thu, Oct 03, 2019 at 06:27:34PM +0100, Rob wrote:
I stumbled on a windows-only bug in pg_basebackup which I've reported as
#16032 (/messages/by-id/16032-4ba56823a2b2805f@postgresql.org).I'm pretty sure I've fixed it in the attached patch.
Could it be possible to keep the discussion on the original thread? I
already replied to it, and there are no problems with discussing
patches dealing with bugs directly on pgsql-bugs. Thanks for caring.
Thanks,
--
Michael