Thread: BUG #6735: PANIC: 42501: could not open control file "global/pg_control": Permission denied
BUG #6735: PANIC: 42501: could not open control file "global/pg_control": Permission denied
From
tsialiam@gmail.com
Date:
The following bug has been logged on the website: Bug reference: 6735 Logged by: Petros Tsialiamanis Email address: tsialiam@gmail.com PostgreSQL version: 8.3.5 Operating system: WinXP Pro SP3 Description:=20=20=20=20=20=20=20=20 Hi,=20 The first time I started the postgresql server as 'Local System' user and I created the PGDATA. Now I am trying to start the postgresql server again as 'pss-svc' user which is member of Administrators group and I take the following error message (I've changed the debug log level) :=20 C:\Documents and Settings\pss-svc>"C:\Program Files\ABC\pgsql\bin\pg_ctl.exe" -W start -D "C:\Documents and Settings\All Users\Application Data\ABC\XYZ\data\pgsql" -o "-p 9432"=20 DEBUG: 00000: postgres: PostmasterMain: initial environ dump: LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:733 DEBUG: 00000: ----------------------------------------- LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:735 DEBUG: 00000: ALLUSERSPROFILE=3DC:\Documents and Settings\All Users LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: APPDATA=3DC:\Documents and Settings\pss-svc\Application Data LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: CommonProgramFiles=3DC:\Program Files\Common Files LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: COMPUTERNAME=3DPETROS-XP LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: ComSpec=3DC:\WINDOWS\system32\cmd.exe LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: FP_NO_HOST_CHECK=3DNO LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: HOMEDRIVE=3DC: LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: HOMEPATH=3D\Documents and Settings\pss-svc LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: LOGONSERVER=3D\\PETROS-XP LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: NUMBER_OF_PROCESSORS=3D1 LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: OS=3DWindows_NT LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: Path=3DC:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: PATHEXT=3D.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: PGDATA=3DC:/Documents and Settings/All Users/Application Data/ABC/XYZ/data/pgsql LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: PGLOCALEDIR=3DC:/Program Files/ABC/pgsql/share/locale LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: PGSYSCONFDIR=3DC:/Program Files/ABC/pgsql/etc LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: PROCESSOR_ARCHITECTURE=3Dx86 LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: PROCESSOR_IDENTIFIER=3Dx86 Family 6 Model 42 Stepping 7, GenuineIntel LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: PROCESSOR_LEVEL=3D6 LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: PROCESSOR_REVISION=3D2a07 LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: ProgramFiles=3DC:\Program Files LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: PROMPT=3D$P$G LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: SESSIONNAME=3DConsole LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: SystemDrive=3DC: LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: SystemRoot=3DC:\WINDOWS LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: TEMP=3DC:\DOCUME~1\pss-svc\LOCALS~1\Temp LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: TMP=3DC:\DOCUME~1\pss-svc\LOCALS~1\Temp LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: USERDOMAIN=3DPETROS-XP LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: USERNAME=3Dpss-svc LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: USERPROFILE=3DC:\Documents and Settings\pss-svc LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: windir=3DC:\WINDOWS LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: LC_COLLATE=3DEnglish_United States.1252 LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: LC_CTYPE=3DEnglish_United States.1252 LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: LC_MONETARY=3DC LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: LC_NUMERIC=3DC LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: LC_TIME=3DC LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:738 DEBUG: 00000: ----------------------------------------- LOCATION: PostmasterMain, .\src\backend\postmaster\postmaster.c:740 DEBUG: 00000: mapped win32 error code 80 to 17 LOCATION: _dosmaperr, .\src\port\win32error.c:182 DEBUG: 00000: TZ "Europe/London" matches Windows timezone "GMT Daylight Time" LOCATION: identify_system_timezone, .\src\timezone\pgtz.c:1027 DEBUG: 00000: invoking IpcMemoryCreate(size=3D37281792) LOCATION: CreateSharedMemoryAndSemaphores, .\src\backend\storage\ipc\ipci.c:128 DEBUG: 00000: mapped win32 error code 5 to 13 LOCATION: _dosmaperr, .\src\port\win32error.c:182 PANIC: 42501: could not open control file "global/pg_control": Permission denied LOCATION: ReadControlFile, .\src\backend\access\transam\xlog.c:3904 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. server starting
Re: BUG #6735: PANIC: 42501: could not open control file "global/pg_control": Permission denied
From
Craig Ringer
Date:
On 07/13/2012 09:00 PM, tsialiam@gmail.com wrote: > The following bug has been logged on the website: > > Bug reference: 6735 > Logged by: Petros Tsialiamanis > Email address: tsialiam@gmail.com > PostgreSQL version: 8.3.5 > Operating system: WinXP Pro SP3 > Description: > > Hi, > The first time I started the postgresql server as 'Local System' user and I > created the PGDATA. Now I am trying to start the postgresql server again as > 'pss-svc' user which is member of Administrators group and I take the > following error message (I've changed the debug log level) The server shouldn't crash at the end, but otherwise this is all misconfiguration of your system. If you change the service account, you need to change the permissions on the PostgreSQL data directory to match the new service account credentials. > DEBUG: 00000: mapped win32 error code 5 to 13 > LOCATION: _dosmaperr, .\src\port\win32error.c:182 > PANIC: 42501: could not open control file "global/pg_control": Permission > denied > LOCATION: ReadControlFile, .\src\backend\access\transam\xlog.c:3904 > > This application has requested the Runtime to terminate it in an unusual > way. > Please contact the application's support team for more information. > server starting > I'm not sure why it's crashing here, but you're running such an ancient version that it's hard to care. If you can reproduce the crash with the latest 8.3 point release it might be worth a look. -- Craig Ringer
Re: BUG #6735: PANIC: 42501: could not open control file "global/pg_control": Permission denied
From
Craig Ringer
Date:
On 07/14/2012 12:18 AM, Petros Tsialiamanis wrote: > Thank you very much for your reply. Thanks for coming back and re-testing with a modern PostgreSQL. PostgreSQL 9.1 isn't compatible with databases from 8.3, so you can't actually run Pg 9.1 directly against a datadir from 8.3; that's why I suggested the latest 8.3 point release. However, your startup should be failing with a message telling you this, not with a permissions error then (more importantly) a crash. Is there any antivirus software on this computer? If so, what is it? Does excluding the PostgreSQL data directory, PostgreSQL executable directory, and (if the AV supports it) adding process exclusions for "postmaster.exe" and "postgres.exe" have any effect? > The 'pss-svc' user is member of the administrators group and has full > permissions for PostgreSQL data directory. It clearly doesn't, because PostgreSQL is getting "permission denied" from the OS when accessing global/pg_control. Maybe you need to apply permissions recursively? Remember that on Win7, membership of the Administrators group doesn't grant the ability to perform file operations as administrator directly. It grants the ability to create privileged processes that can then perform those operations using implicit or explicit "run as administrator" functionality. I can't off the top of my head think of a safe way on Windows to test if a file is writable as a given user without potentially changing its contents. On Linux I'd say "run touch /path/name" but there's no touch command on Windows. global\pg_control is a binary file so you can't just open it and save it in notepad (DO NOT DO THIS) as it'll corrupt it hopelessly, and Windows doesn't come with a binary-safe editor. > I reproduced the crash with PostgreSQL version 9.1.4.12152 with the > following output : [snip] > LOCATION: _dosmaperr, .\src\port\win32error.c:186 > PANIC: 42501: could not open control file "global/pg_control": > Permission denied > LOCATION: ReadControlFile, .\src\backend\access\transam\xlog.c:4687 > > This application has requested the Runtime to terminate it in an unusual way. > Please contact the application's support team for more information. > ****************************************************************** OK, that's not very nice behaviour - it should be doing a clean exit after it fails to read global/pg_control . Hmm. I'm not sure off the top of my head how to tackle tracking that down without a debugger. I don't really have time at the moment to set up a test environment under Windows and see if I can reproduce it. Ideas anyone? Can someone with a Windows box use pg_ctl to try to start a new Pg instance against a datadir with an unwritable pg_control ? -- Craig Ringer
Re: BUG #6735: PANIC: 42501: could not open control file "global/pg_control": Permission denied
From
John R Pierce
Date:
On 07/13/12 6:00 AM, tsialiam@gmail.com wrote: > PANIC: 42501: could not open control file "global/pg_control": Permission > denied start a CMD prompt ('dos') via 'run as admin'. from this privileged command window, CACLS \path\to\pg\data /T /E /G pss-svc:(OI)(CI)F then try restarting postgres. LOCAL_SYSTEM created the files, and owns them. Oh, the pss-svc user should not be a member of Administrators. -- john r pierce N 37, W 122 santa cruz ca mid-left coast
Re: BUG #6735: PANIC: 42501: could not open control file "global/pg_control": Permission denied
From
Tom Lane
Date:
Craig Ringer <ringerc@ringerc.id.au> writes: > PostgreSQL 9.1 isn't compatible with databases from 8.3, so you can't > actually run Pg 9.1 directly against a datadir from 8.3; that's why I > suggested the latest 8.3 point release. > However, your startup should be failing with a message telling you this, > not with a permissions error then (more importantly) a crash. Well, the reason that's a PANIC is that ReadControlFile is coded that way: fd = BasicOpenFile(XLOG_CONTROL_FILE, O_RDWR | PG_BINARY, S_IRUSR | S_IWUSR); if (fd < 0) ereport(PANIC, (errcode_for_file_access(), errmsg("could not open control file \"%s\": %m", XLOG_CONTROL_FILE))); Perhaps it should be only FATAL instead, but that seems like a quibble. If it can't read pg_control, the server ain't starting. It is curious though that the OP gets this far, because the server would previously have tried to read PG_VERSION and postgresql.conf, which if it were a simple wrong-account problem should likewise have been unreadable. Your thought about AV software may be the right explanation. regards, tom lane
Re: BUG #6735: PANIC: 42501: could not open control file "global/pg_control": Permission denied
From
Craig Ringer
Date:
On 07/16/2012 07:54 PM, Petros Tsialiamanis wrote: > Sorry for the misunderstanding. When I said that I reproduced the > error in 9.1 version, I mean that I created the PGDATA with 9.1 > postgresql server as 'local system' user and after that I tried to > start the postgresql server as 'pss-svc' user and I took the error > message which I sent with my previous mail. So there isn't any > incompatibility problem with PGDATA. OK, that helps explain that. Thanks for following up with a current version, then. I have a Windows VM on this machine so I'll see if I can reproduce that issue. I need a bit more information to do so. Specifically I need to know how the user 'pss-svc' was created, what its group memberships are and what its rights are ("can interact with desktop", "login as service", etc). > As 'pss-svc' user I can open, read and write to the pg_control file ( > I took backup of this file first ). Open, read and write using what command(s) or programs? Is there a UAC prompt? Did you run the CACLS command you were given by John? > I have exactly the same problem when I try to start progresql server > as Administrator instead of 'pss-svc' user If 'pss-svc' user is a member of Administrators or Local Admins, remove the user from those groups. Pg is quite insistent about not being run as admin. That shouldn't be the cause of these issues, as it's quite explicit about it when that's the case, but it's a good idea anyway. Personally I think Pg should let this up to the user, but that's the way it is for now. -- Craig Ringer
Re: BUG #6735: PANIC: 42501: could not open control file "global/pg_control": Permission denied
From
Petros Tsialiamanis
Date:
On 14 July 2012 05:56, Craig Ringer <ringerc@ringerc.id.au> wrote: > On 07/14/2012 12:18 AM, Petros Tsialiamanis wrote: >> >> Thank you very much for your reply. > > Thanks for coming back and re-testing with a modern PostgreSQL. > > PostgreSQL 9.1 isn't compatible with databases from 8.3, so you can't > actually run Pg 9.1 directly against a datadir from 8.3; that's why I > suggested the latest 8.3 point release. > > However, your startup should be failing with a message telling you this, not > with a permissions error then (more importantly) a crash. > Sorry for the misunderstanding. When I said that I reproduced the error in 9.1 version, I mean that I created the PGDATA with 9.1 postgresql server as 'local system' user and after that I tried to start the postgresql server as 'pss-svc' user and I took the error message which I sent with my previous mail. So there isn't any incompatibility problem with PGDATA. > Is there any antivirus software on this computer? If so, what is it? Does > excluding the PostgreSQL data directory, PostgreSQL executable directory, > and (if the AV supports it) adding process exclusions for "postmaster.exe" > and "postgres.exe" have any effect? > There isn't any antivirus software on my computer. >> The 'pss-svc' user is member of the administrators group and has full >> permissions for PostgreSQL data directory. > > It clearly doesn't, because PostgreSQL is getting "permission denied" from > the OS when accessing global/pg_control. Maybe you need to apply permissions > recursively? As 'pss-svc' user I can open, read and write to the pg_control file ( I took backup of this file first ). I have exactly the same problem when I try to start progresql server as Administrator instead of 'pss-svc' user > > Remember that on Win7, membership of the Administrators group doesn't grant > the ability to perform file operations as administrator directly. It grants > the ability to create privileged processes that can then perform those > operations using implicit or explicit "run as administrator" functionality. > > I can't off the top of my head think of a safe way on Windows to test if a > file is writable as a given user without potentially changing its contents. > On Linux I'd say "run touch /path/name" but there's no touch command on > Windows. global\pg_control is a binary file so you can't just open it and > save it in notepad (DO NOT DO THIS) as it'll corrupt it hopelessly, and > Windows doesn't come with a binary-safe editor. > >> I reproduced the crash with PostgreSQL version 9.1.4.12152 with the >> following output : > > [snip] > >> LOCATION: _dosmaperr, .\src\port\win32error.c:186 >> PANIC: 42501: could not open control file "global/pg_control": >> Permission denied >> LOCATION: ReadControlFile, .\src\backend\access\transam\xlog.c:4687 >> >> This application has requested the Runtime to terminate it in an unusual >> way. >> Please contact the application's support team for more information. >> ****************************************************************** > > > OK, that's not very nice behaviour - it should be doing a clean exit after > it fails to read global/pg_control . Hmm. I'm not sure off the top of my > head how to tackle tracking that down without a debugger. I don't really > have time at the moment to set up a test environment under Windows and see > if I can reproduce it. > > Ideas anyone? Can someone with a Windows box use pg_ctl to try to start a > new Pg instance against a datadir with an unwritable pg_control ? > > -- > Craig Ringer