Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id AA03B9FB2C7 for ; Mon, 12 Feb 2007 17:31:37 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 73782-06 for ; Mon, 12 Feb 2007 17:31:30 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 61CF19FA39B for ; Mon, 12 Feb 2007 17:31:28 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id l1CLVO3r013466; Mon, 12 Feb 2007 16:31:24 -0500 (EST) To: "Peter Kovacs" cc: pgsql-admin@postgresql.org Subject: Re: pid file problem In-reply-to: References: Comments: In-reply-to "Peter Kovacs" message dated "Mon, 12 Feb 2007 20:02:22 +0100" Date: Mon, 12 Feb 2007 16:31:24 -0500 Message-ID: <13465.1171315884@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.111 tagged_above=0 required=5 tests=AWL, BAYES_50, SPF_HELO_PASS, SPF_PASS X-Spam-Level: X-Archive-Number: 200702/170 X-Sequence-Number: 24635 "Peter Kovacs" writes: > Please, could you tell me why the pid file is not deleted on shutdown? It looks to me like the postmaster isn't being given enough time to finish shutdown before being forcibly killed. This is not great, but in theory we should always be able to recover from that. You might want to look to see if you can't extend the SIGTERM-to-SIGKILL delay though. > On system startup PostgreSQL 8.1.4 refuses to start due to the pid > file is left over from previous "session" on Solaris 10 x86. That should not happen; it should always be possible to detect whether the file is stale, *if* your start script is written correctly. Per the comment in miscinit.c: * If the PID in the lockfile is our own PID or our parent's PID, then * the file must be stale (probably left over from a previous system * boot cycle). We need this test because of the likelihood that a * reboot will assign exactly the same PID as we had in the previous * reboot. Also, if there is just one more process launch in this * reboot than in the previous one, the lockfile might mention our * parent's PID. We can reject that since we'd never be launched * directly by a competing postmaster. We can't detect grandparent * processes unfortunately, but if the init script is written * carefully then all but the immediate parent shell will be * root-owned processes and so the kill test will fail with EPERM. * * We can treat the EPERM-error case as okay because that error * implies that the existing process has a different userid than we * do, which means it cannot be a competing postmaster. If the start script is written in a way that creates multiple levels of postgres-owned processes, you should fix it. On Linux something like this works: su -l postgres -c "/usr/bin/postmaster ... &" >> "$PGLOG" 2>&1 < /dev/null Don't use "su 'pg_ctl ...'" to start the postmaster, because it creates exactly the hazard situation of an extra postgres-owned process. Also, if you are trying to start multiple postmasters at boot, this technique is insufficient unless you run each one under a distinct userid (which is probably a good idea anyway on security grounds). regards, tom lane