dbTalk Databases Forums  

Re: [BUGS] postgresql-[any version] from FreeBSD ports - startup problems after crash

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] postgresql-[any version] from FreeBSD ports - startup problems after crash in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Re: [BUGS] postgresql-[any version] from FreeBSD ports - startup problems after crash - 05-15-2006 , 08:24 AM






Ruslan A Dautkhanov <rusland (AT) scn (DOT) ru> writes:
Quote:
Server rebooted occasionally after power failure.
And I have stale postmaster.pid file, so postmaster didn't start with error
bill postgres[600]: [1-1] FATAL: file "postmaster.pid" already exists
You probably need a newer postgres version (you didn't say what you are
using) and/or a more carefully written start script.

Your proposed change in the start script is useless --- do you think the
postmaster doesn't check that already? Furthermore, it's actually
dangerous for reasons we need not get into here; suffice to say that
automated removal of that lock file is NOT a good idea.

The problem comes up when the startup timing is just different enough
that the PID belonging to the postmaster in the previous boot cycle now
belongs to the shell that's launching it. The postmaster sees a live
process of the correct userid (ie, postgres) and has to assume that
that's a pre-existing postmaster.

We've fixed this in recent releases by having the postmaster also check
for a match to its parent process ID (getppid). The care in the start
script comes because this only works for one level up. Therefore, you
can't "su -c pg_ctl start ..." because that would create three levels of
postgres-owned processes (shell, pg_ctl, postmaster) and if the PID
count is off by 2 instead of 1 then we still lose. You have to invoke
the postmaster directly, "su -c postmaster ...". (Hm, actually it might
work to do "su -c 'exec pg_ctl ...'" ... I have not tried that.)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default Re: [BUGS] postgresql-[any version] from FreeBSD ports - startup problems after crash - 05-15-2006 , 02:01 PM






On Mon, May 15, 2006 at 09:23:33AM -0400, Tom Lane wrote:
Quote:
We've fixed this in recent releases by having the postmaster also check
for a match to its parent process ID (getppid). The care in the start
script comes because this only works for one level up. Therefore, you
can't "su -c pg_ctl start ..." because that would create three levels of
postgres-owned processes (shell, pg_ctl, postmaster) and if the PID
count is off by 2 instead of 1 then we still lose. You have to invoke
the postmaster directly, "su -c postmaster ...". (Hm, actually it might
work to do "su -c 'exec pg_ctl ...'" ... I have not tried that.)
Except that the shell that's running su would be root, not pgsql, at
least in the case of FreeBSD. The guts of the current port's rc.d file
are:

su -l ${postgresql_user} -c "exec ${command} ${command_args} ${rc_arg}"
--
Jim C. Nasby, Sr. Engineering Consultant jnasby (AT) pervasive (DOT) com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend


Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: [BUGS] postgresql-[any version] from FreeBSD ports - startup problems after crash - 05-15-2006 , 02:13 PM



"Jim C. Nasby" <jnasby (AT) pervasive (DOT) com> writes:
Quote:
Except that the shell that's running su would be root, not pgsql, at
least in the case of FreeBSD. The guts of the current port's rc.d file
are:

su -l ${postgresql_user} -c "exec ${command} ${command_args} ${rc_arg}"
Yeah, but what's the ${command} ?

If it's pg_ctl then all he's missing is the recent change to check
getppid. If it's execing postmaster directly then maybe we need
another theory.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq


Reply With Quote
  #4  
Old   
AT
 
Posts: n/a

Default Re: [BUGS] postgresql-[any version] from FreeBSD ports - startup problems after crash - 05-15-2006 , 02:22 PM



Tom Lane wrote:
Quote:
"Jim C. Nasby" <jnasby (AT) pervasive (DOT) com> writes:
Except that the shell that's running su would be root, not pgsql, at
least in the case of FreeBSD. The guts of the current port's rc.d
file are:

su -l ${postgresql_user} -c "exec ${command} ${command_args}
${rc_arg}"

Yeah, but what's the ${command} ?

If it's pg_ctl then all he's missing is the recent change to check
getppid. If it's execing postmaster directly then maybe we need
another theory.
It's pg_ctl....

command=${prefix}/bin/pg_ctl


--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 512-248-2683 E-Mail: ler (AT) lerctr (DOT) org
US Mail: 430 Valona Loop, Round Rock, TX 78681-3893


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings


Reply With Quote
  #5  
Old   
AT
 
Posts: n/a

Default Re: [BUGS] postgresql-[any version] from FreeBSD ports - startup problems after crash - 05-15-2006 , 02:51 PM



On Mon, May 15, 2006 at 02:20:51PM -0500, Larry Rosenman wrote:
Quote:
Yeah, but what's the ${command} ?

If it's pg_ctl then all he's missing is the recent change to check
getppid. If it's execing postmaster directly then maybe we need
another theory.

It's pg_ctl....

command=${prefix}/bin/pg_ctl
http://lnk.nu/freebsd.org/9fu.tmpl is the file in ports CVS.
http://jim.nasby.net/010.pgsql.sh.txt is the file as it exists on one of
my systems.
--
Jim C. Nasby, Sr. Engineering Consultant jnasby (AT) pervasive (DOT) com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.