Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZxPZa-0004Ym-VF for pgsql-bugs@arkaria.postgresql.org; Sat, 14 Nov 2015 01:24:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZxPZZ-0005MV-H3 for pgsql-bugs@arkaria.postgresql.org; Sat, 14 Nov 2015 01:24:09 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZxPZX-0005ME-KF for pgsql-bugs@postgresql.org; Sat, 14 Nov 2015 01:24:07 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZxPZU-0003uo-F8 for pgsql-bugs@postgresql.org; Sat, 14 Nov 2015 01:24:06 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1ZxPZS-0003hi-FF; Fri, 13 Nov 2015 20:24:02 -0500 Date: Fri, 13 Nov 2015 20:24:02 -0500 From: Bruce Momjian To: manu@coopapotheken.be Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space Message-ID: <20151114012402.GC27916@momjian.us> References: <20151112195735.9795.39615@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="azLHFNyN32YCQGCU" Content-Disposition: inline In-Reply-To: <20151112195735.9795.39615@wrigleys.postgresql.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -2.2 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --azLHFNyN32YCQGCU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Nov 12, 2015 at 07:57:35PM +0000, manu@coopapotheken.be wrote: > The following bug has been logged on the website: > > Bug reference: 13774 > Logged by: Manu Joye > Email address: manu@coopapotheken.be > PostgreSQL version: 9.4.5 > Operating system: Windows server 2008r2 > Description: > > running pg_upgrade yields no warnings when there is not enough disk space to > do the upgrade. I upgraded a server with about 10 databases following the > instructions as provided on the website here. Everything seemed to have gone > well except that some tables in various databases just vanished (pgadmin > complained about missing files) . Upon inspection I noticed the HD had only > a couple of KB of free space left. pg_upgrade seemed to have just restored > what it could and then exited without warning! > > We caught it early on and could restore from backups but a check on required > free disk space before upgrade should be implemented or, if that doesn't > work, at least a warning from pg_upgrade that something went wrong. Thank you for the report. This is embarrassing, but the code was testing for the wrong return value on Windows. We used a macro to define the same symbol on Windows and Unix (pg_copy_file), but for Windows, we should have been testing for zero, while the code only tested for a -1 return failure. You can see the Windows failure zero return value defined here: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363851%28v=vs.85%29.aspx Return value If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError. We do something similar for hard links, but we create a wrapper function to return the proper value (-1), and we call it twice, so it seems wise to keep that unchanged. The attached patch fixes this and will be applied to all active branches in the next minor release. Sorry for the bug. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Roman grave inscription + --azLHFNyN32YCQGCU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="copyfile.diff" diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c new file mode 100644 index 79d9390..37eb832 *** a/src/bin/pg_upgrade/file.c --- b/src/bin/pg_upgrade/file.c *************** copyAndUpdateFile(pageCnvCtx *pageConver *** 34,40 **** { if (pageConverter == NULL) { ! if (pg_copy_file(src, dst, force) == -1) return getErrorText(errno); else return NULL; --- 34,44 ---- { if (pageConverter == NULL) { ! #ifndef WIN32 ! if (copy_file(src, dst, force) == -1) ! #else ! if (CopyFile(src, dst, force) == 0) ! #endif return getErrorText(errno); else return NULL; diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h new file mode 100644 index 13aa891..fa4661b *** a/src/bin/pg_upgrade/pg_upgrade.h --- b/src/bin/pg_upgrade/pg_upgrade.h *************** extern char *output_files[]; *** 70,76 **** #ifndef WIN32 - #define pg_copy_file copy_file #define pg_mv_file rename #define pg_link_file link #define PATH_SEPARATOR '/' --- 70,75 ---- *************** extern char *output_files[]; *** 82,88 **** #define ECHO_QUOTE "'" #define ECHO_BLANK "" #else - #define pg_copy_file CopyFile #define pg_mv_file pgrename #define pg_link_file win32_pghardlink #define PATH_SEPARATOR '\\' --- 81,86 ---- --azLHFNyN32YCQGCU Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --azLHFNyN32YCQGCU--