pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
10+ messages / 6 participants
[nested] [flat]

* BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
@ 2015-11-12 19:57  manu@coopapotheken.be
  0 siblings, 1 reply; 10+ messages in thread

From: manu@coopapotheken.be @ 2015-11-12 19:57 UTC (permalink / raw)
  To: pgsql-bugs

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.


Kind regards,

Manu

PS I LOVE postgresql, let that be clear. Thanks a whole lot to the whole
team for making this DBMS as awesome as it is. 


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
@ 2015-11-14 01:24  Bruce Momjian <bruce@momjian.us>
  parent: manu@coopapotheken.be
  0 siblings, 2 replies; 10+ messages in thread

From: Bruce Momjian @ 2015-11-14 01:24 UTC (permalink / raw)
  To: manu@coopapotheken.be; +Cc: pgsql-bugs

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  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Roman grave inscription                             +

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

copyfile.diff (text/x-diff, 1.3K) download 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 ----
^ permalink raw reply [nested|flat] 10+ messages in thread

* Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
@ 2015-11-14 16:47  Bruce Momjian <bruce@momjian.us>
  parent: Bruce Momjian <bruce@momjian.us>
  1 sibling, 1 reply; 10+ messages in thread

From: Bruce Momjian @ 2015-11-14 16:47 UTC (permalink / raw)
  To: manu@coopapotheken.be; +Cc: pgsql-bugs

On Fri, Nov 13, 2015 at 08:24:02PM -0500, Bruce Momjian wrote:
> 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.

Patch applied and backpatched through 9.1.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Roman grave inscription                             +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
@ 2015-11-14 19:02  Manu Joye <manu.joye@coopapotheken.be>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 10+ messages in thread

From: Manu Joye @ 2015-11-14 19:02 UTC (permalink / raw)
  To: 'Bruce Momjian' <bruce@momjian.us>; +Cc: pgsql-bugs

Thanks for the quick fix, Bruce. Much appreciated.

Manu

-----Original Message-----
From: Bruce Momjian [mailto:bruce@momjian.us] 
Sent: zaterdag 14 november 2015 17:48
To: manu@coopapotheken.be
Cc: pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without
enough disk space

On Fri, Nov 13, 2015 at 08:24:02PM -0500, Bruce Momjian wrote:
> 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.

Patch applied and backpatched through 9.1.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Roman grave inscription                             +



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
@ 2015-11-14 21:30  'Bruce Momjian' <bruce@momjian.us>
  parent: Manu Joye <manu.joye@coopapotheken.be>
  0 siblings, 0 replies; 10+ messages in thread

From: Bruce Momjian @ 2015-11-14 21:30 UTC (permalink / raw)
  To: Manu Joye <manu.joye@coopapotheken.be>; +Cc: pgsql-bugs

On Sat, Nov 14, 2015 at 08:02:09PM +0100, Manu Joye wrote:
> Thanks for the quick fix, Bruce. Much appreciated.

I am a little worried that bug might have masked other pg_upgrade
Windows copy failures.  I am glad you were able to see the problem so
clearly.

---------------------------------------------------------------------------



> 
> Manu
> 
> -----Original Message-----
> From: Bruce Momjian [mailto:bruce@momjian.us] 
> Sent: zaterdag 14 november 2015 17:48
> To: manu@coopapotheken.be
> Cc: pgsql-bugs@postgresql.org
> Subject: Re: [BUGS] BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without
> enough disk space
> 
> On Fri, Nov 13, 2015 at 08:24:02PM -0500, Bruce Momjian wrote:
> > 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.
> 
> Patch applied and backpatched through 9.1.
> 
> -- 
>   Bruce Momjian  <bruce@momjian.us>        http://momjian.us
>   EnterpriseDB                             http://enterprisedb.com
> 
> + As you are, so once was I. As I am, so you will be. +
> + Roman grave inscription                             +
> 

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Roman grave inscription                             +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
@ 2015-11-18 04:43  Noah Misch <noah@leadboat.com>
  parent: Bruce Momjian <bruce@momjian.us>
  1 sibling, 1 reply; 10+ messages in thread

From: Noah Misch @ 2015-11-18 04:43 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: manu@coopapotheken.be; pgsql-bugs

On Fri, Nov 13, 2015 at 08:24:02PM -0500, Bruce Momjian wrote:
> 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)

> *** 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);

Thanks.  This passage of code has at least two other problems on Windows.  The
third CopyFile() argument means the opposite of the third copy_file()
argument.  Next, getErrorText() is wrong on Windows:

const char *
getErrorText(int errNum)
{
#ifdef WIN32
	_dosmaperr(GetLastError());
#endif
	return pg_strdup(strerror(errNum));
}

Calling _dosmaperr() to set errno is futile, because we nonetheless proceed to
use the passed-in errNum.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
@ 2015-11-18 13:49  Bruce Momjian <bruce@momjian.us>
  parent: Noah Misch <noah@leadboat.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Bruce Momjian @ 2015-11-18 13:49 UTC (permalink / raw)
  To: Noah Misch <noah@leadboat.com>; +Cc: manu@coopapotheken.be; pgsql-bugs

On Tue, Nov 17, 2015 at 11:43:34PM -0500, Noah Misch wrote:
> On Fri, Nov 13, 2015 at 08:24:02PM -0500, Bruce Momjian wrote:
> > 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)
> 
> > *** 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);
> 
> Thanks.  This passage of code has at least two other problems on Windows.  The
> third CopyFile() argument means the opposite of the third copy_file()
> argument.  Next, getErrorText() is wrong on Windows:
> 
> const char *
> getErrorText(int errNum)
> {
> #ifdef WIN32
> 	_dosmaperr(GetLastError());
> #endif
> 	return pg_strdup(strerror(errNum));
> }
> 
> Calling _dosmaperr() to set errno is futile, because we nonetheless proceed to
> use the passed-in errNum.

Very good points.  The attached patch fixes the copy parameter and
addresses the errno issue by just using errno direcdtly after the
_dosmaperr call.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Roman grave inscription                             +

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

copy.diff (text/x-diff, 16.4K) download diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c new file mode 100644 index 41d4606..539f197 *** a/src/bin/pg_upgrade/check.c --- b/src/bin/pg_upgrade/check.c *************** create_script_for_cluster_analyze(char * *** 421,427 **** if ((script = fopen_priv(*analyze_script_file_name, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! *analyze_script_file_name, getErrorText(errno)); #ifndef WIN32 /* add shebang header */ --- 421,427 ---- if ((script = fopen_priv(*analyze_script_file_name, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! *analyze_script_file_name, getErrorText()); #ifndef WIN32 /* add shebang header */ *************** create_script_for_cluster_analyze(char * *** 476,482 **** #ifndef WIN32 if (chmod(*analyze_script_file_name, S_IRWXU) != 0) pg_fatal("Could not add execute permission to file \"%s\": %s\n", ! *analyze_script_file_name, getErrorText(errno)); #endif if (os_info.user_specified) --- 476,482 ---- #ifndef WIN32 if (chmod(*analyze_script_file_name, S_IRWXU) != 0) pg_fatal("Could not add execute permission to file \"%s\": %s\n", ! *analyze_script_file_name, getErrorText()); #endif if (os_info.user_specified) *************** create_script_for_old_cluster_deletion(c *** 532,538 **** if ((script = fopen_priv(*deletion_script_file_name, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! *deletion_script_file_name, getErrorText(errno)); #ifndef WIN32 /* add shebang header */ --- 532,538 ---- if ((script = fopen_priv(*deletion_script_file_name, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! *deletion_script_file_name, getErrorText()); #ifndef WIN32 /* add shebang header */ *************** create_script_for_old_cluster_deletion(c *** 588,594 **** #ifndef WIN32 if (chmod(*deletion_script_file_name, S_IRWXU) != 0) pg_fatal("Could not add execute permission to file \"%s\": %s\n", ! *deletion_script_file_name, getErrorText(errno)); #endif check_ok(); --- 588,594 ---- #ifndef WIN32 if (chmod(*deletion_script_file_name, S_IRWXU) != 0) pg_fatal("Could not add execute permission to file \"%s\": %s\n", ! *deletion_script_file_name, getErrorText()); #endif check_ok(); *************** check_for_isn_and_int8_passing_mismatch( *** 790,796 **** found = true; if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! output_path, getErrorText(errno)); if (!db_used) { fprintf(script, "Database: %s\n", active_db->db_name); --- 790,796 ---- found = true; if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! output_path, getErrorText()); if (!db_used) { fprintf(script, "Database: %s\n", active_db->db_name); *************** check_for_reg_data_type_usage(ClusterInf *** 893,899 **** found = true; if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! output_path, getErrorText(errno)); if (!db_used) { fprintf(script, "Database: %s\n", active_db->db_name); --- 893,899 ---- found = true; if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! output_path, getErrorText()); if (!db_used) { fprintf(script, "Database: %s\n", active_db->db_name); *************** check_for_jsonb_9_4_usage(ClusterInfo *c *** 984,990 **** found = true; if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! output_path, getErrorText(errno)); if (!db_used) { fprintf(script, "Database: %s\n", active_db->db_name); --- 984,990 ---- found = true; if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! output_path, getErrorText()); if (!db_used) { fprintf(script, "Database: %s\n", active_db->db_name); *************** get_bin_version(ClusterInfo *cluster) *** 1032,1038 **** if ((output = popen(cmd, "r")) == NULL || fgets(cmd_output, sizeof(cmd_output), output) == NULL) pg_fatal("Could not get pg_ctl version data using %s: %s\n", ! cmd, getErrorText(errno)); pclose(output); --- 1032,1038 ---- if ((output = popen(cmd, "r")) == NULL || fgets(cmd_output, sizeof(cmd_output), output) == NULL) pg_fatal("Could not get pg_ctl version data using %s: %s\n", ! cmd, getErrorText()); pclose(output); diff --git a/src/bin/pg_upgrade/controldata.c b/src/bin/pg_upgrade/controldata.c new file mode 100644 index 8a86e45..8da4ce3 *** a/src/bin/pg_upgrade/controldata.c --- b/src/bin/pg_upgrade/controldata.c *************** get_control_data(ClusterInfo *cluster, b *** 120,126 **** if ((output = popen(cmd, "r")) == NULL) pg_fatal("Could not get control data using %s: %s\n", ! cmd, getErrorText(errno)); /* Only in <= 9.2 */ if (GET_MAJOR_VERSION(cluster->major_version) <= 902) --- 120,126 ---- if ((output = popen(cmd, "r")) == NULL) pg_fatal("Could not get control data using %s: %s\n", ! cmd, getErrorText()); /* Only in <= 9.2 */ if (GET_MAJOR_VERSION(cluster->major_version) <= 902) diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c new file mode 100644 index 7d31912..92c3766 *** a/src/bin/pg_upgrade/exec.c --- b/src/bin/pg_upgrade/exec.c *************** pid_lock_file_exists(const char *datadir *** 191,197 **** /* ENOTDIR means we will throw a more useful error later */ if (errno != ENOENT && errno != ENOTDIR) pg_fatal("could not open file \"%s\" for reading: %s\n", ! path, getErrorText(errno)); return false; } --- 191,197 ---- /* ENOTDIR means we will throw a more useful error later */ if (errno != ENOENT && errno != ENOTDIR) pg_fatal("could not open file \"%s\" for reading: %s\n", ! path, getErrorText()); return false; } *************** check_data_dir(const char *pg_data) *** 285,291 **** if (stat(subDirName, &statBuf) != 0) report_status(PG_FATAL, "check for \"%s\" failed: %s\n", ! subDirName, getErrorText(errno)); else if (!S_ISDIR(statBuf.st_mode)) report_status(PG_FATAL, "%s is not a directory\n", subDirName); --- 285,291 ---- if (stat(subDirName, &statBuf) != 0) report_status(PG_FATAL, "check for \"%s\" failed: %s\n", ! subDirName, getErrorText()); else if (!S_ISDIR(statBuf.st_mode)) report_status(PG_FATAL, "%s is not a directory\n", subDirName); *************** check_bin_dir(ClusterInfo *cluster) *** 309,315 **** /* check bindir */ if (stat(cluster->bindir, &statBuf) != 0) report_status(PG_FATAL, "check for \"%s\" failed: %s\n", ! cluster->bindir, getErrorText(errno)); else if (!S_ISDIR(statBuf.st_mode)) report_status(PG_FATAL, "%s is not a directory\n", cluster->bindir); --- 309,315 ---- /* check bindir */ if (stat(cluster->bindir, &statBuf) != 0) report_status(PG_FATAL, "check for \"%s\" failed: %s\n", ! cluster->bindir, getErrorText()); else if (!S_ISDIR(statBuf.st_mode)) report_status(PG_FATAL, "%s is not a directory\n", cluster->bindir); *************** validate_exec(const char *dir, const cha *** 352,358 **** */ if (stat(path, &buf) < 0) pg_fatal("check for \"%s\" failed: %s\n", ! path, getErrorText(errno)); else if (!S_ISREG(buf.st_mode)) pg_fatal("check for \"%s\" failed: not an executable file\n", path); --- 352,358 ---- */ if (stat(path, &buf) < 0) pg_fatal("check for \"%s\" failed: %s\n", ! path, getErrorText()); else if (!S_ISREG(buf.st_mode)) pg_fatal("check for \"%s\" failed: not an executable file\n", path); diff --git a/src/bin/pg_upgrade/file.c b/src/bin/pg_upgrade/file.c new file mode 100644 index 37eb832..c84783c *** a/src/bin/pg_upgrade/file.c --- b/src/bin/pg_upgrade/file.c *************** copyAndUpdateFile(pageCnvCtx *pageConver *** 37,45 **** #ifndef WIN32 if (copy_file(src, dst, force) == -1) #else ! if (CopyFile(src, dst, force) == 0) #endif ! return getErrorText(errno); else return NULL; } --- 37,45 ---- #ifndef WIN32 if (copy_file(src, dst, force) == -1) #else ! if (CopyFile(src, dst, !force) == 0) #endif ! return getErrorText(); else return NULL; } *************** linkAndUpdateFile(pageCnvCtx *pageConver *** 121,127 **** return "Cannot in-place update this cluster, page-by-page conversion is required"; if (pg_link_file(src, dst) == -1) ! return getErrorText(errno); else return NULL; } --- 121,127 ---- return "Cannot in-place update this cluster, page-by-page conversion is required"; if (pg_link_file(src, dst) == -1) ! return getErrorText(); else return NULL; } *************** check_hard_link(void) *** 219,225 **** { pg_fatal("Could not create hard link between old and new data directories: %s\n" "In link mode the old and new data directories must be on the same file system volume.\n", ! getErrorText(errno)); } unlink(new_link_file); } --- 219,225 ---- { pg_fatal("Could not create hard link between old and new data directories: %s\n" "In link mode the old and new data directories must be on the same file system volume.\n", ! getErrorText()); } unlink(new_link_file); } diff --git a/src/bin/pg_upgrade/function.c b/src/bin/pg_upgrade/function.c new file mode 100644 index 04492a5..0fb8c31 *** a/src/bin/pg_upgrade/function.c --- b/src/bin/pg_upgrade/function.c *************** check_loadable_libraries(void) *** 214,220 **** if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! output_path, getErrorText(errno)); fprintf(script, "Could not load library \"%s\"\n%s\n", lib, PQerrorMessage(conn)); --- 214,220 ---- if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) pg_fatal("Could not open file \"%s\": %s\n", ! output_path, getErrorText()); fprintf(script, "Could not load library \"%s\"\n%s\n", lib, PQerrorMessage(conn)); diff --git a/src/bin/pg_upgrade/option.c b/src/bin/pg_upgrade/option.c new file mode 100644 index 90f1401..a8571f0 *** a/src/bin/pg_upgrade/option.c --- b/src/bin/pg_upgrade/option.c *************** adjust_data_dir(ClusterInfo *cluster) *** 423,429 **** if ((output = popen(cmd, "r")) == NULL || fgets(cmd_output, sizeof(cmd_output), output) == NULL) pg_fatal("Could not get data directory using %s: %s\n", ! cmd, getErrorText(errno)); pclose(output); --- 423,429 ---- if ((output = popen(cmd, "r")) == NULL || fgets(cmd_output, sizeof(cmd_output), output) == NULL) pg_fatal("Could not get data directory using %s: %s\n", ! cmd, getErrorText()); pclose(output); diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c new file mode 100644 index 00cc938..4a7281b *** a/src/bin/pg_upgrade/pg_upgrade.c --- b/src/bin/pg_upgrade/pg_upgrade.c *************** setup(char *argv0, bool *live_check) *** 224,230 **** /* get path to pg_upgrade executable */ if (find_my_exec(argv0, exec_path) < 0) ! pg_fatal("Could not get path name to pg_upgrade: %s\n", getErrorText(errno)); /* Trim off program name and keep just path */ *last_dir_separator(exec_path) = '\0'; --- 224,230 ---- /* get path to pg_upgrade executable */ if (find_my_exec(argv0, exec_path) < 0) ! pg_fatal("Could not get path name to pg_upgrade: %s\n", getErrorText()); /* Trim off program name and keep just path */ *last_dir_separator(exec_path) = '\0'; diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h new file mode 100644 index fa4661b..a43dff5 *** a/src/bin/pg_upgrade/pg_upgrade.h --- b/src/bin/pg_upgrade/pg_upgrade.h *************** void pg_fatal(const char *fmt,...) pg_a *** 460,466 **** void end_progress_output(void); void prep_status(const char *fmt,...) pg_attribute_printf(1, 2); void check_ok(void); ! const char *getErrorText(int errNum); unsigned int str2uint(const char *str); void pg_putenv(const char *var, const char *val); --- 460,466 ---- void end_progress_output(void); void prep_status(const char *fmt,...) pg_attribute_printf(1, 2); void check_ok(void); ! const char *getErrorText(void); unsigned int str2uint(const char *str); void pg_putenv(const char *var, const char *val); diff --git a/src/bin/pg_upgrade/relfilenode.c b/src/bin/pg_upgrade/relfilenode.c new file mode 100644 index c22df42..bfde1b1 *** a/src/bin/pg_upgrade/relfilenode.c --- b/src/bin/pg_upgrade/relfilenode.c *************** transfer_relfile(pageCnvCtx *pageConvert *** 258,264 **** else pg_fatal("error while checking for file existence \"%s.%s\" (\"%s\" to \"%s\"): %s\n", map->nspname, map->relname, old_file, new_file, ! getErrorText(errno)); } close(fd); } --- 258,264 ---- else pg_fatal("error while checking for file existence \"%s.%s\" (\"%s\" to \"%s\"): %s\n", map->nspname, map->relname, old_file, new_file, ! getErrorText()); } close(fd); } diff --git a/src/bin/pg_upgrade/tablespace.c b/src/bin/pg_upgrade/tablespace.c new file mode 100644 index ce7097e..a20cbc6 *** a/src/bin/pg_upgrade/tablespace.c --- b/src/bin/pg_upgrade/tablespace.c *************** get_tablespace_paths(void) *** 91,97 **** else report_status(PG_FATAL, "cannot stat() tablespace directory \"%s\": %s\n", ! os_info.old_tablespaces[tblnum], getErrorText(errno)); } if (!S_ISDIR(statBuf.st_mode)) report_status(PG_FATAL, --- 91,97 ---- else report_status(PG_FATAL, "cannot stat() tablespace directory \"%s\": %s\n", ! os_info.old_tablespaces[tblnum], getErrorText()); } if (!S_ISDIR(statBuf.st_mode)) report_status(PG_FATAL, diff --git a/src/bin/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c new file mode 100644 index 7f328f0..5a2ecbb *** a/src/bin/pg_upgrade/util.c --- b/src/bin/pg_upgrade/util.c *************** get_user_info(char **user_name_p) *** 236,252 **** * getErrorText() * * Returns the text of the error message for the given error number - * - * This feature is factored into a separate function because it is - * system-dependent. */ const char * ! getErrorText(int errNum) { #ifdef WIN32 _dosmaperr(GetLastError()); #endif ! return pg_strdup(strerror(errNum)); } --- 236,249 ---- * getErrorText() * * Returns the text of the error message for the given error number */ const char * ! getErrorText(void) { #ifdef WIN32 _dosmaperr(GetLastError()); #endif ! return pg_strdup(strerror(errno)); } diff --git a/src/bin/pg_upgrade/version.c b/src/bin/pg_upgrade/version.c new file mode 100644 index 9954dae..b93c414 *** a/src/bin/pg_upgrade/version.c --- b/src/bin/pg_upgrade/version.c *************** new_9_0_populate_pg_largeobject_metadata *** 49,55 **** if (!check_mode) { if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) ! pg_fatal("could not open file \"%s\": %s\n", output_path, getErrorText(errno)); fprintf(script, "\\connect %s\n", quote_identifier(active_db->db_name)); fprintf(script, --- 49,55 ---- if (!check_mode) { if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) ! pg_fatal("could not open file \"%s\": %s\n", output_path, getErrorText()); fprintf(script, "\\connect %s\n", quote_identifier(active_db->db_name)); fprintf(script, *************** old_9_3_check_for_line_data_type_usage(C *** 143,149 **** { found = true; if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) ! pg_fatal("could not open file \"%s\": %s\n", output_path, getErrorText(errno)); if (!db_used) { fprintf(script, "Database: %s\n", active_db->db_name); --- 143,149 ---- { found = true; if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) ! pg_fatal("could not open file \"%s\": %s\n", output_path, getErrorText()); if (!db_used) { fprintf(script, "Database: %s\n", active_db->db_name);
^ permalink raw reply [nested|flat] 10+ messages in thread

* Re: Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
@ 2015-11-18 14:30  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 10+ messages in thread

From: Tom Lane @ 2015-11-18 14:30 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: Noah Misch <noah@leadboat.com>; manu@coopapotheken.be; pgsql-bugs

Bruce Momjian <bruce@momjian.us> writes:
> Very good points.  The attached patch fixes the copy parameter and
> addresses the errno issue by just using errno direcdtly after the
> _dosmaperr call.

You did not change the comment

   *	Returns the text of the error message for the given error number

even though no error number is a "given" parameter anymore.  Maybe
"... for the most-recently-reported error"?

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
@ 2015-11-18 14:42  Bruce Momjian <bruce@momjian.us>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 10+ messages in thread

From: Bruce Momjian @ 2015-11-18 14:42 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Noah Misch <noah@leadboat.com>; manu@coopapotheken.be; pgsql-bugs

On Wed, Nov 18, 2015 at 09:30:45AM -0500, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > Very good points.  The attached patch fixes the copy parameter and
> > addresses the errno issue by just using errno direcdtly after the
> > _dosmaperr call.
> 
> You did not change the comment
> 
>    *	Returns the text of the error message for the given error number
> 
> even though no error number is a "given" parameter anymore.  Maybe
> "... for the most-recently-reported error"?

Good point.  I have changed it to "Returns the text of the most recent
error".

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Roman grave inscription                             +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Re: BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space
@ 2015-11-24 22:19  Bruce Momjian <bruce@momjian.us>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 0 replies; 10+ messages in thread

From: Bruce Momjian @ 2015-11-24 22:19 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Noah Misch <noah@leadboat.com>; manu@coopapotheken.be; pgsql-bugs

On Wed, Nov 18, 2015 at 09:42:35AM -0500, Bruce Momjian wrote:
> On Wed, Nov 18, 2015 at 09:30:45AM -0500, Tom Lane wrote:
> > Bruce Momjian <bruce@momjian.us> writes:
> > > Very good points.  The attached patch fixes the copy parameter and
> > > addresses the errno issue by just using errno direcdtly after the
> > > _dosmaperr call.
> > 
> > You did not change the comment
> > 
> >    *	Returns the text of the error message for the given error number
> > 
> > even though no error number is a "given" parameter anymore.  Maybe
> > "... for the most-recently-reported error"?
> 
> Good point.  I have changed it to "Returns the text of the most recent
> error".

Patch applied and backpatched through 9.1.  I used a smaller patch, same
behavior, on pre-9.4 because the removal of the getErrorText() argument
were too invasive.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Roman grave inscription                             +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2015-11-24 22:19 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 19:57 BUG #13774: upgrade from 9.1 to 9.4 'succeeds' without enough disk space manu@coopapotheken.be
2015-11-14 01:24 ` Bruce Momjian <bruce@momjian.us>
2015-11-14 16:47   ` Bruce Momjian <bruce@momjian.us>
2015-11-14 19:02     ` Manu Joye <manu.joye@coopapotheken.be>
2015-11-14 21:30       ` 'Bruce Momjian' <bruce@momjian.us>
2015-11-18 04:43   ` Noah Misch <noah@leadboat.com>
2015-11-18 13:49     ` Bruce Momjian <bruce@momjian.us>
2015-11-18 14:30       ` Tom Lane <tgl@sss.pgh.pa.us>
2015-11-18 14:42         ` Bruce Momjian <bruce@momjian.us>
2015-11-24 22:19           ` Bruce Momjian <bruce@momjian.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox