Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 3A49464FD03 for ; Tue, 18 Nov 2008 01:38:54 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 60186-06 for ; Tue, 18 Nov 2008 01:38:51 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from defout.telus.net (defout.telus.net [204.209.205.13]) by mail.postgresql.org (Postfix) with ESMTP id AE5ED64FC91 for ; Tue, 18 Nov 2008 01:38:50 -0400 (AST) Received: from localhost ([204.209.205.55]) by priv-edmwes48.telusplanet.net (InterMail vM.7.08.03.00 201-2186-126-20070710) with ESMTP id <20081118053844.DESQ27986.priv-edmwes48.telusplanet.net@localhost> for ; Mon, 17 Nov 2008 22:38:44 -0700 Received: from 75.157.220.38 ( [75.157.220.38]) as user a3a18850@204.209.205.54 by legacywebmail.telus.net with HTTP; Mon, 17 Nov 2008 21:38:44 -0800 Message-ID: <1226986724.492254e42cda7@legacywebmail.telus.net> Date: Mon, 17 Nov 2008 21:38:44 -0800 From: Mischa Sandberg To: pgsql-admin@postgresql.org Subject: Re: Reliably determining whether the server came up References: <20081116212002.7DFE91E81690@mx2.hub.org> In-Reply-To: <20081116212002.7DFE91E81690@mx2.hub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 75.157.220.38 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/92 X-Sequence-Number: 30746 Comment below: Joshua D. Drake wrote: > On Sat, 2008-11-15 at 12:29 -0800, Mischa Sandberg wrote: >> Quoting "H. Hall" : >>> Mischa Sandberg wrote: >>> >>>> I've been trying to work out a reliable script to determine, >>>> after pg_ctl start, that the server is done attempting >>>> to come up, and that it has either succeeded OR FAILED. >>>> This is for several hundred unattended appliance-type servers, >>>> currently on PG 8.0 but soon to be on 8.3 >>>> >>> Why don't you try to create a connection to a db on each server? >> Thanks, but that only tells me if the server is up at the time of trying >> to connect. > > Actually it doesn't. If you are using any standard library to connect if > the server is not ready to accept connections, it will tell you when you > connect. If the server failed to come up, you won't get a connection at > all, if you try to connect and you are able to connect but not initiate > a session and appropriate response will be sent. > Joshua D. Drake Exactly. :-) Also, once you take a look at your solution code a light bulb may go off. Hey! This code could also be used to test the health of my db servers during production! If I just execute it in a timer thread . . . Hmmm. --cheers, HH -- H. Hall ReedyRiver Group LLC www.reedyriver.com Well, I'll look further at it. I originally did start with while pg_ctl status && ! psql -l; do nothing; done The cases I've had to catch include: - startup so slow that postmaster.pid has still not been created when the first pg_ctl status exits, returning 'no server'. - a pg_xlog drive going sour (some low-end hardware is, well, crap), so pg_ctl status says server is up but connects get 'FATAL: the database system is shutting down' forever. ... and I'm guessing that other server failure states will produce other messages (with FATAL not always meaning real fatality). -- Engineers think that equations approximate reality. Physicists think that reality approximates the equations. Mathematicians never make the connection.