From: Bruce Momjian <bruce@momjian.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Magnus Hagander <magnus@hagander.net>
Cc: Ashesh Vashi <ashesh.vashi@enterprisedb.com>
Cc: Mark Llewellyn <mark_llewellyn@adp.com>
Cc: pgsql-hackers@postgresql.org
Cc: Sujeet Rajguru <sujeet.rajguru@enterprisedb.com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: Fri, 12 Nov 2010 11:47:27 -0500 (EST)
Message-ID: <201011121647.oACGlRF10346@momjian.us> (raw)
In-Reply-To: <9721.1289574206@sss.pgh.pa.us>
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > Uh, I still cannot reproduce the failure:
>
> I would imagine you need -w option on the start. The whole issue
> here is whether start's wait-for-server-start code works.
Thanks, I am now able to reproduce this. I was able to get this to
report the .pgpass problem:
$ psql postgres
psql: FATAL: password authentication failed for user "postgres"
password retrieved from file "/u/postgres/.pgpass"
$ pg_ctl stop
waiting for server to shut down.... done
server stopped
$ pg_ctl -w -l /dev/null start
waiting for server to start....FATAL: password authentication failed
for user "postgres"
password retrieved from file "/u/postgres/.pgpass"
.FATAL: password authentication failed for user "postgres"
password retrieved from file "/u/postgres/.pgpass"
.FATAL: password authentication failed for user "postgres"
password retrieved from file "/u/postgres/.pgpass"
.^C
I basically report the connection error string if it starts with "FATAL:".
I originally tried to check for an ERRCODE_INVALID_PASSWORD error field
(see // comments), but it seems there is no way to access this, i.e.
PQgetResult(conn) on a connection failure is always NULL.
Anyway, perhaps FATAL is a better test because it will report any major
failure, not just a .pgpass one.
Patch attached.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachments:/pgpatches/pg_ctl (text/x-diff, 1.2K) downloaddiff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.cindex 14d36b5..df71c16 100644
*** a/src/bin/pg_ctl/pg_ctl.c
--- b/src/bin/pg_ctl/pg_ctl.c
*************** typedef enum
*** 70,75 ****
--- 70,78 ----
} CtlCommand;
#define DEFAULT_WAIT 60
+ //+ ///* This is part of the protocol so just define it */+ //#define ERRCODE_INVALID_PASSWORD "28P01"
static bool do_wait = false;
static bool wait_set = false;
*************** test_postmaster_connection(bool do_check
*** 511,516 ****
--- 514,523 ----
if ((conn = PQconnectdb(connstr)) != NULL &&
(PQstatus(conn) == CONNECTION_OK ||
PQconnectionNeedsPassword(conn)))
+ // /* only works with >= 9.0 servers */+ // (PQgetResult(conn) &&+ // strcmp(PQresultErrorField(PQgetResult(conn), PG_DIAG_SQLSTATE),+ // ERRCODE_INVALID_PASSWORD) == 0)))
{
PQfinish(conn);
success = true;
*************** test_postmaster_connection(bool do_check
*** 518,523 ****
--- 525,533 ----
}
else
{
+ /* report fatal errors like invalid .pgpass passwords */+ if (strncmp(PQerrorMessage(conn), "FATAL:", strlen("FATAL:")) == 0)+ fputs(PQerrorMessage(conn), stderr);
PQfinish(conn);
#if defined(WIN32)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: bruce@momjian.us, tgl@sss.pgh.pa.us, magnus@hagander.net, ashesh.vashi@enterprisedb.com, mark_llewellyn@adp.com, pgsql-hackers@postgresql.org, sujeet.rajguru@enterprisedb.com
Subject: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
In-Reply-To: <201011121647.oACGlRF10346@momjian.us>
References: <9721.1289574206@sss.pgh.pa.us> <201011121647.oACGlRF10346@momjian.us>
* 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