pg_upgrade failure on Windows Server - Mailing list pgsql-bugs

From Asif Naeem
Subject pg_upgrade failure on Windows Server
Date
Msg-id CAEB4t-NpXGiP5Bqvv3P+d+x=V4BqE+Awg+G7ennBn8icPXep_g@mail.gmail.com
Whole thread Raw
Responses Re: pg_upgrade failure on Windows Server  (Asif Naeem <anaeem.it@gmail.com>)
List pgsql-bugs
Hi,

It is been observed that pg_upgrade fail to upgrade on Windows Server
machine if being run as Administrator user (other local users works fine),
It fail with the following error message i.e.

> ""c:\pg93\bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "c:\pgdata93" -o
> "-p 3333 -b -c autovacuum_multixact_freeze_max_age=3D2000000000  -c
> synchronous_commit=3Doff -c fsync=3Doff -c full_page_writes=3Doff" start =
>>
> "pg_upgrade_server_start.log" 2>&1"
> *failure*
> There were problems executing """c:\pg93\bin/pg_ctl" -w -l
> "pg_upgrade_server.log" -D "c:\pgdata93" -o "-p 3333 -b -c
> autovacuum_multixact_freeze_max_age=3D2000000000  -c synchronous_commit=
=3Doff
> -c fsync=3Doff -c full_page_writes=3Doff" start >>
> "pg_upgrade_server_start.log" 2>&1""
> Consult the last few lines of "pg_upgrade_server_start.log" or
> "pg_upgrade_server.log" for
> the probable cause of the failure.
> connection to database failed: could not connect to server: Connection
> refused (0x0000274D/10061)
>         Is the server running on host "localhost" (127.0.0.1) and accepti=
ng
>         TCP/IP connections on port 3333?
>
> could not connect to new postmaster started with the command:
> "c:\pg93\bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "c:\pgdata93" -o "-=
p
> 3333 -b -c autovacuum_multixact_freeze_max_age=3D2000000000  -c
> synchronous_commit=3Doff -c fsync=3Doff -c full_page_writes=3Doff" start
> Failure, exiting


pg_upgrade_server.log

> PANIC:  could not open control file "global/pg_control": Permission denie=
d


"global/pg_control=E2=80=9D file in data directory owned by
"BUILTIN\Administrators=E2=80=9D that was owned by =E2=80=9CAdministrator=
=E2=80=9D user before
pg_upgrade. I have verified it on Windows Server 2003/2008 R2/2012.

Steps to reproduce the issue :

> 1. Login as Administrator on Windows Server 2012 or Windows Server 2008
> 2. On command prompt run "c:\pg92\bin\initdb -D c:\pgdata92"
> 3. On command prompt run "c:\pg93\bin\initdb -D c:\pgdata93"
> 4. On command prompt run  "c:\pg93\bin\pg_upgrade -d c:\pgdata92 -D
> c:\pgdata93 -b c:\pg92\bin -B c:\pg93\bin -p 2222 -P 3333 -v"


Issue is reproducible with PG 9.2, 9.3 and 9.4. It is caused by
pg_resetxlog utility (It is internally used by pg_upgrade) that fail to
keep correct file permissions/ownership (as required by dbserver process)
while rewriting "global/pg_control=E2=80=9D in data directory. pg_resetxlog=
 utility
don=E2=80=99t sandbox and make changes in data directory, when it is being =
run as
Administrator ; it create files that are owned by "BUILTIN\Administrators=
=E2=80=9D
group. pg_ctl fails because it is using CreateRestrictedProcess() to
sandbox and give up administrator privileges that make it fail to open
"global/pg_control=E2=80=9D file (that is now owned by "BUILTIN\Administrat=
ors=E2=80=9D
group) in write mode i.e.

2014-12-19 03:19:34 PST PANIC: 42501: could not open control file
> "global/pg_control": Permission denied
> 2014-12-19 03:19:34 PST LOCATION: ReadControlFile,
> src\backend\access\transam\xlog.c:4458


I think Domain users that are members of Administrators group suffer from
same problem. On Windows Server 2003, changing Group Policy =E2=80=9CSystem
objects: Default owner for objects created by members of the Administrators
group=E2=80=9D to =E2=80=9CObject Creator=E2=80=9D fixes the problem. Micro=
soft obsolete this Group
Policy in later version of Windows Server. I have tried a workaround (
http://support.microsoft.com/kb/947721) on Windows Server 2008 R2 but it
seems did not worked for me. As it is default behavior for Windows Server,
I would suggest to use CreateRestrictedProcess function (sandbox or
restricted tokens approach) in pg_resetxlog utility or explicitly change
ownership to current user instead of "BUILTIN\Administrators=E2=80=9D group=
 if
required (If you agree with the approach I can submit patch for this).
Please do let me know if I missed something or more information is
required. Thanks.

Regards,
Muhammad Asif Naeem

pgsql-bugs by date:

Previous
From: YTheon
Date:
Subject: Re: BUG #12328: can't install the postgresql
Next
From: elegirmeister@gmail.com
Date:
Subject: BUG #12410: PgAdmin 1.20 crash on start (OS X 10.10.1)