pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: H. Hall <hhall1001@reedyriver.com>
To: Mischa Sandberg <mischa_sandberg@telus.net>
To: pgsql-admin@postgresql.org
Subject: Re: Reliably determining whether the server came up
Date: Sat, 15 Nov 2008 13:43:45 -0500
Message-ID: <491F1861.4060403@reedyriver.com> (raw)
In-Reply-To: <1226527535.491b532f4c45e@legacywebmail.telus.net>
References: <1226527535.491b532f4c45e@legacywebmail.telus.net>

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?

HH
> Haven't found anything in the archives.
> I want to determine success/failure without time-outs, since:
> the db is restarted every time a server gets an upgrade,
> and it can get several upgrades in a batch, and the cpu/disk load 
> during an upgrade is highly variable; a restart with no
> recovery may still require as much as a minute to get to 'ready'.
>
> We also need to restart the server several hundred times
> in our in-house system tests.
>
> So pg_ctl -w start is not an option, even if the timeout were
> configurable to under a minute.
>
> The best I have that doesn't involve modifying pg_ctl is:
>
> # Hand-compute $NEXT_LOG from postgresql.conf
> # parameters (log_directory) and (log_filename).
> # Replace %S format with a '??' wildcard (yech).
>
> $ TEMP_LOG=/tmp/pg.$PGPORT.log
> $ touch $NEXT_LOG >$TEMP_LOG
> $ FROM=`awk 'END {print NR+1}' $NEXT_LOG`
> $ pg_ctl start -s -l $TEMPLOG
> $ while tail +$FROM $NEXT_LOG | ! egrep -hw
> 'FATAL|PANIC|DETAIL|ready|shutting|^postmaster cannot' $TEMP_LOG -; do
> sleep 1; done
>
> The nasty cases are when the server fails (exits)
> without being able to create its std log file (e.g. 
> error in postgresql.conf). 
>
> So I'm down to patching start_postmaster in pg_ctl.c 
> to use popen("... & echo $!") instead of system("... &"),
> then make test_postmaster_connection do a kill(0,pid)
> if PQsetdbLogin fails.
>
> Any suggestions appreciated.
>   





view thread (12+ messages)  latest in thread

Message-ID: <491F1861.4060403@reedyriver.com>
Permalink:  ../491F1861.4060403@reedyriver.com/
Also on:    postgresql.org/message-id/491F1861.4060403@reedyriver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: hhall1001@reedyriver.com, mischa_sandberg@telus.net
  Subject: Re: Reliably determining whether the server came up
  In-Reply-To: <491F1861.4060403@reedyriver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox