Thread: Upgrading 9.0 to 9.3 - permission denied to pg_upgrade_utility.log

Upgrading 9.0 to 9.3 - permission denied to pg_upgrade_utility.log

From
Russell Keane
Date:

Hi,

 

We’re trying to upgrade a 9.0 database to 9.3 using pg_upgrade. The upgrade must be automated so a manual pg_dump / pg_restore is not an option.

We use the following command:

D:\PostgreSQL\9.3\Data>"c:\Program Files (x86)\PostgreSQL\9.3\bin\pg_upgrade.exe" -d "D:\PostgreSQL\Data" -D "D:\PostgreSQL\9.3\Data" -b "C:\Program Files (x86)\PostgreSQL\9.0\bin" -B "C:\Program Files (x86)\PostgreSQL\9.3\bin" -u postgres -c -P 5432

 

This is on a Windows 7 64 bit environment.

We’ve given the postgres windows user full permissions to all folders involved and are running the upgrade in a cmd prompt opened with runas  /user:postgres

 

The upgrade works all the way up until the final hurdle where, in the pg_upgrade_utility.log the following statement appears:

command: ""C:\Program Files (x86)\PostgreSQL\9.3\bin/initdb" --sync-only "D:\PostgreSQL\9.3\Data" >> "pg_upgrade_utility.log" 2>&1"

syncing data to disk ... initdb: could not open file "D:/PostgreSQL/9.3/Data/pg_upgrade_utility.log": Permission denied

 

It seems odd that the log states that it has no permission to the file that it’s writing the error in but I guessed it might be because both pg_upgrade and initdb are both trying to write to the same file. I therefore tried the initdb command manually and it still fails with the same message.

 

After this failure, if we try to run PG 9.3 it starts up fine and everything seems to be in order. All the data exists and there are no errors in the PG log at startup. I don’t really want to simply ignore this error but it doesn’t seem to be causing any issues.

 

Any ideas?

 

 

Regards,

 

Russell Keane

INPS

 

Tel:         +44 (0)20 7501 7277

 

Follow us on twitter | visit www.inps.co.uk

 



Registered name: In Practice Systems Ltd.
Registered address: The Bread Factory, 1a Broughton Street, London, SW8 3QJ
Registered Number: 1788577
Registered in England
Visit our Internet Web site at www.inps.co.uk
The information in this internet email is confidential and is intended solely for the addressee. Access, copying or re-use of information in it by anyone else is not authorised. Any views or opinions presented are solely those of the author and do not necessarily represent those of INPS or any of its affiliates. If you are not the intended recipient please contact is.helpdesk@inps.co.uk

Re: Upgrading 9.0 to 9.3 - permission denied to pg_upgrade_utility.log

From
Bruce Momjian
Date:
On Thu, Aug  7, 2014 at 09:42:13AM +0100, Russell Keane wrote:
> Hi,
>
>
>
> We’re trying to upgrade a 9.0 database to 9.3 using pg_upgrade. The upgrade
> must be automated so a manual pg_dump / pg_restore is not an option.
>
> We use the following command:
>
> D:\PostgreSQL\9.3\Data>"c:\Program Files (x86)\PostgreSQL\9.3\bin\
> pg_upgrade.exe" -d "D:\PostgreSQL\Data" -D "D:\PostgreSQL\9.3\Data" -b "C:\
> Program Files (x86)\PostgreSQL\9.0\bin" -B "C:\Program Files (x86)\PostgreSQL\
> 9.3\bin" -u postgres -c -P 5432
>
>
>
> This is on a Windows 7 64 bit environment.
>
> We’ve given the postgres windows user full permissions to all folders involved
> and are running the upgrade in a cmd prompt opened with runas  /user:postgres
>
>
>
> The upgrade works all the way up until the final hurdle where, in the
> pg_upgrade_utility.log the following statement appears:
>
> command: ""C:\Program Files (x86)\PostgreSQL\9.3\bin/initdb" --sync-only "D:\
> PostgreSQL\9.3\Data" >> "pg_upgrade_utility.log" 2>&1"
>
> syncing data to disk ... initdb: could not open file "D:/PostgreSQL/9.3/Data/
> pg_upgrade_utility.log": Permission denied

Uh, it would appear you are running pg_upgrade from _inside_ the 9.3
data directory.  That should work, but it would probably be better to
run it in another directory where you also have write permission.  I
think the problem is that initdb --sync-only is syncing those files to
disk as you are writing to the log file.

We have had Windows problems of two processes writing to the same file,
but that is usually a different error message, e.g.

     * For some reason, Windows issues a file-in-use error if we write data to
     * the log file from a non-primary thread just before we create a
     * subprocess that also writes to the same log file.  One fix is to sleep
     * for 100ms.  A cleaner fix is to write to the log file _after_ the
     * subprocess has completed, so we do this only when writing from a
     * non-primary thread.  fflush(), running system() twice, and pre-creating
     * the file do not see to help.

I think that returns a "share violation" error.

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

  + Everyone has their own god. +


Re: Upgrading 9.0 to 9.3 - permission denied to pg_upgrade_utility.log

From
Russell Keane
Date:

-----Original Message-----
From: Bruce Momjian [mailto:bruce@momjian.us] 
Sent: 07 August 2014 17:43
To: Russell Keane
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Upgrading 9.0 to 9.3 - permission denied to pg_upgrade_utility.log

On Thu, Aug  7, 2014 at 09:42:13AM +0100, Russell Keane wrote:
> Hi,
> 
>  
> 
> We’re trying to upgrade a 9.0 database to 9.3 using pg_upgrade. The 
> upgrade must be automated so a manual pg_dump / pg_restore is not an option.
> 
> We use the following command:
> 
> D:\PostgreSQL\9.3\Data>"c:\Program Files (x86)\PostgreSQL\9.3\bin\ 
> pg_upgrade.exe" -d "D:\PostgreSQL\Data" -D "D:\PostgreSQL\9.3\Data" -b 
> "C:\ Program Files (x86)\PostgreSQL\9.0\bin" -B "C:\Program Files 
> (x86)\PostgreSQL\ 9.3\bin" -u postgres -c -P 5432
> 
>  
> 
> This is on a Windows 7 64 bit environment.
> 
> We’ve given the postgres windows user full permissions to all folders 
> involved and are running the upgrade in a cmd prompt opened with runas  
> /user:postgres
> 
>  
> 
> The upgrade works all the way up until the final hurdle where, in the 
> pg_upgrade_utility.log the following statement appears:
> 
> command: ""C:\Program Files (x86)\PostgreSQL\9.3\bin/initdb" 
> --sync-only "D:\ PostgreSQL\9.3\Data" >> "pg_upgrade_utility.log" 2>&1"
> 
> syncing data to disk ... initdb: could not open file 
> "D:/PostgreSQL/9.3/Data/
> pg_upgrade_utility.log": Permission denied

Uh, it would appear you are running pg_upgrade from _inside_ the 9.3 data directory.  That should work, but it would
probablybe better to run it in another directory where you also have write permission.  I think the problem is that
initdb--sync-only is syncing those files to disk as you are writing to the log file.
 

We have had Windows problems of two processes writing to the same file, but that is usually a different error message,
e.g.

     * For some reason, Windows issues a file-in-use error if we write data to
     * the log file from a non-primary thread just before we create a
     * subprocess that also writes to the same log file.  One fix is to sleep
     * for 100ms.  A cleaner fix is to write to the log file _after_ the
     * subprocess has completed, so we do this only when writing from a
     * non-primary thread.  fflush(), running system() twice, and pre-creating
     * the file do not see to help.

I think that returns a "share violation" error.

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

  + Everyone has their own god. +


Excellent! That's fixed it for us.

Thanks Bruce,

Re: Upgrading 9.0 to 9.3 - permission denied to pg_upgrade_utility.log

From
Bruce Momjian
Date:
On Tue, Aug 12, 2014 at 10:59:16AM +0100, Russell Keane wrote:
> > The upgrade works all the way up until the final hurdle where, in the
> > pg_upgrade_utility.log the following statement appears:
> >
> > command: ""C:\Program Files (x86)\PostgreSQL\9.3\bin/initdb"
> > --sync-only "D:\ PostgreSQL\9.3\Data" >> "pg_upgrade_utility.log" 2>&1"
> >
> > syncing data to disk ... initdb: could not open file
> > "D:/PostgreSQL/9.3/Data/
> > pg_upgrade_utility.log": Permission denied
>
> Uh, it would appear you are running pg_upgrade from _inside_ the 9.3 data directory.  That should work, but it would
probablybe better to run it in another directory where you also have write permission.  I think the problem is that
initdb--sync-only is syncing those files to disk as you are writing to the log file. 
>
> We have had Windows problems of two processes writing to the same file, but that is usually a different error
message,e.g. 
>
>      * For some reason, Windows issues a file-in-use error if we write data to
>      * the log file from a non-primary thread just before we create a
>      * subprocess that also writes to the same log file.  One fix is to sleep
>      * for 100ms.  A cleaner fix is to write to the log file _after_ the
>      * subprocess has completed, so we do this only when writing from a
>      * non-primary thread.  fflush(), running system() twice, and pre-creating
>      * the file do not see to help.
>
> I think that returns a "share violation" error.

I have applied the attached patch for 9.5 which will generate a clearer
error in this case, attached.

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

  + Everyone has their own god. +

Attachment

Re: Upgrading 9.0 to 9.3 - permission denied to pg_upgrade_utility.log

From
Russell Keane
Date:

-----Original Message-----
From: Bruce Momjian [mailto:bruce@momjian.us]
Sent: 15 August 2014 17:06
To: Russell Keane
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Upgrading 9.0 to 9.3 - permission denied to pg_upgrade_utility.log

On Tue, Aug 12, 2014 at 10:59:16AM +0100, Russell Keane wrote:
> > The upgrade works all the way up until the final hurdle where, in
> > the pg_upgrade_utility.log the following statement appears:
> >
> > command: ""C:\Program Files (x86)\PostgreSQL\9.3\bin/initdb"
> > --sync-only "D:\ PostgreSQL\9.3\Data" >> "pg_upgrade_utility.log" 2>&1"
> >
> > syncing data to disk ... initdb: could not open file
> > "D:/PostgreSQL/9.3/Data/
> > pg_upgrade_utility.log": Permission denied
>
> Uh, it would appear you are running pg_upgrade from _inside_ the 9.3 data directory.  That should work, but it would
probablybe better to run it in another directory where you also have write permission.  I think the problem is that
initdb--sync-only is syncing those files to disk as you are writing to the log file. 
>
> We have had Windows problems of two processes writing to the same file, but that is usually a different error
message,e.g. 
>
>      * For some reason, Windows issues a file-in-use error if we write data to
>      * the log file from a non-primary thread just before we create a
>      * subprocess that also writes to the same log file.  One fix is to sleep
>      * for 100ms.  A cleaner fix is to write to the log file _after_ the
>      * subprocess has completed, so we do this only when writing from a
>      * non-primary thread.  fflush(), running system() twice, and pre-creating
>      * the file do not see to help.
>
> I think that returns a "share violation" error.

I have applied the attached patch for 9.5 which will generate a clearer error in this case, attached.

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

  + Everyone has their own god. +




Thank you once again.

Regards,

Russell.