Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 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.

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

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

  + Everyone has their own god. +
diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c
new file mode 100644
index e0a3c6d..2e7c347
*** a/contrib/pg_upgrade/option.c
--- b/contrib/pg_upgrade/option.c
*************** parseCommandLine(int argc, char *argv[])
*** 229,234 ****
--- 229,254 ----
  							 "PGDATAOLD", "-d", "old cluster data resides");
  	check_required_directory(&new_cluster.pgdata, &new_cluster.pgconfig,
  							 "PGDATANEW", "-D", "new cluster data resides");
+ 
+ #ifndef WIN32
+ 	/*
+ 	 * On Windows, initdb --sync-only will fail with a "Permission denied"
+ 	 * error on file pg_upgrade_utility.log if pg_upgrade is run inside
+ 	 * the new cluster directory, so we do a check here.
+ 	 */
+ 	{
+ 		char	cwd[MAXPGPATH], new_cluster_pgdata[MAXPGPATH];
+ 
+ 		strlcpy(new_cluster_pgdata, new_cluster.pgdata, MAXPGPATH);
+ 		canonicalize_path(new_cluster_pgdata);
+ 		
+ 		if (!getcwd(cwd, MAXPGPATH))
+ 			pg_fatal("cannot find current directory\n");
+ 		canonicalize_path(cwd);
+ 		if (path_is_prefix_of_path(new_cluster_pgdata, cwd))
+ 			pg_fatal("cannot run pg_upgrade from inside the new cluster data directory on Windows\n");
+ 	}
+ #endif
  }
  
  
-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux