Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running

Lists: pgsql-bugspgsql-hackers
From: "Mark Llewellyn" <mark_llewellyn(at)adp(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-09 16:22:51
Message-ID: 201009091622.o89GMp0V012822@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers


The following bug has been logged online:

Bug reference: 5650
Logged by: Mark Llewellyn
Email address: mark_llewellyn(at)adp(dot)com
PostgreSQL version: 9.0 RC1
Operating system: Windows XP
Description: Postgres service showing as stopped when in fact it is
running
Details:

The postgresql-9.0 service is showing as *not running* in pgAdmin 3 1.12 RC1
and as *stopped* in the Windows services list, although the database is
actually running and I can connect to it and create databases, tables etc.
It also shows multiple postgresql tasks in Windows task manager.
However, because Windows XP is not aware that the postgresql-9.0 service is
running it is not possible to stop the service.


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Mark Llewellyn <mark_llewellyn(at)adp(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-17 01:23:53
Message-ID: AANLkTik+nmm3ADJe7=Zk5fet-uWPbztZaN=RN780QKNQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Thu, Sep 9, 2010 at 12:22 PM, Mark Llewellyn <mark_llewellyn(at)adp(dot)com> wrote:
>
> The following bug has been logged online:
>
> Bug reference:      5650
> Logged by:          Mark Llewellyn
> Email address:      mark_llewellyn(at)adp(dot)com
> PostgreSQL version: 9.0 RC1
> Operating system:   Windows XP
> Description:        Postgres service showing as stopped when in fact it is
> running
> Details:
>
> The postgresql-9.0 service is showing as *not running* in pgAdmin 3 1.12 RC1
> and as *stopped* in the Windows services list, although the database is
> actually running and I can connect to it and create databases, tables etc.
> It also shows multiple postgresql tasks in Windows task manager.
> However, because Windows XP is not aware that the postgresql-9.0 service is
> running it is not possible to stop the service.

Maybe this is a dumb question, but how did you start the service?

And applying the good old Windows troubleshooting meme... if you
reboot, does that fix it?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company


From: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>
To: Mark Llewellyn <mark_llewellyn(at)adp(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-17 03:51:09
Message-ID: AANLkTinGKCkc1maDGXyMjcWRoKAXx2KhMDdQazT-jsgB@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Hi Mark,

On of my college (Sujeet) has found a way to reproduce the same behaviour.
1. Installed PG 9.0 on Win XP SP3
2. Stop the Postgresql-9.0 service from service manager console
3. Create pgpass.conf in postgres (service account) user's profile with an
incorrect password deliberately.
(Refer: http://www.postgresql.org/docs/8.4/interactive/libpq-pgpass.html)
4. Now start the postgresql-9.0 service, it will return an error and the
status
shows stopped
5. However i could connect to the psql shell and get the prompt which means
the server is running.

So, please check if pgpass.conf file exists in service account (postgres)
user's %APPDATA%\postgresql directory with wrong password.

--
Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise Postgres Company<http://www.enterprisedb.com>

On Thu, Sep 9, 2010 at 9:52 PM, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>wrote:

>
> The following bug has been logged online:
>
> Bug reference: 5650
> Logged by: Mark Llewellyn
> Email address: mark_llewellyn(at)adp(dot)com
> PostgreSQL version: 9.0 RC1
> Operating system: Windows XP
> Description: Postgres service showing as stopped when in fact it is
> running
> Details:
>
> The postgresql-9.0 service is showing as *not running* in pgAdmin 3 1.12
> RC1
> and as *stopped* in the Windows services list, although the database is
> actually running and I can connect to it and create databases, tables etc.
> It also shows multiple postgresql tasks in Windows task manager.
> However, because Windows XP is not aware that the postgresql-9.0 service is
> running it is not possible to stop the service.
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>
Cc: Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-24 13:23:32
Message-ID: AANLkTinqm4cY_e6C5cYh9Uf7gzX_-Vy475Z3ZO6_PKkr@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Fri, Sep 17, 2010 at 05:51, Ashesh Vashi
<ashesh(dot)vashi(at)enterprisedb(dot)com> wrote:
> Hi Mark,
>
> On of my college (Sujeet) has found a way to reproduce the same behaviour.
> 1. Installed PG 9.0 on Win XP SP3
> 2. Stop the Postgresql-9.0 service from service manager console
> 3. Create pgpass.conf in postgres (service account) user's profile with an
> incorrect password deliberately.
> (Refer: http://www.postgresql.org/docs/8.4/interactive/libpq-pgpass.html)
> 4. Now start the postgresql-9.0 service, it will return an error and the
> status
>    shows stopped
> 5. However i could connect to the psql shell and get the prompt which means
>     the server is running.

I took a quick look at the code, and from what I can tell this is
because PQconnectionNeedsPassword() always returns false if a
pgpass.conf has been used. There is no handling the case where pgpass
is used, but has an incorrect password.

Does anybody recall the specific reason for this? Do we need a way for
pg_ctl to figure this out, or do we need to change it in
PQconnecitonNeedsPassword()?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-24 14:04:55
Message-ID: 13967.1285337095@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> I took a quick look at the code, and from what I can tell this is
> because PQconnectionNeedsPassword() always returns false if a
> pgpass.conf has been used. There is no handling the case where pgpass
> is used, but has an incorrect password.

Why should it? That code is complicated enough, I don't think it needs
to have a behavior of pretending that a wrong entry isn't there.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-24 14:15:08
Message-ID: AANLkTimFTNqkPUsUhfWqHtThpu6iJ6OYH1etFYXa1tM8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Fri, Sep 24, 2010 at 16:04, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
>> I took a quick look at the code, and from what I can tell this is
>> because PQconnectionNeedsPassword() always returns false if a
>> pgpass.conf has been used. There is no handling the case where pgpass
>> is used, but has an incorrect password.
>
> Why should it?  That code is complicated enough, I don't think it needs
> to have a behavior of pretending that a wrong entry isn't there.

In that case, we should probably teach pg_ctl about this case, no?
Since it clearly gives an incorrect message to the user now...

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-24 14:42:48
Message-ID: 4C9CB8E8.3040106@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On 09/24/2010 10:15 AM, Magnus Hagander wrote:
> On Fri, Sep 24, 2010 at 16:04, Tom Lane<tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Magnus Hagander<magnus(at)hagander(dot)net> writes:
>>> I took a quick look at the code, and from what I can tell this is
>>> because PQconnectionNeedsPassword() always returns false if a
>>> pgpass.conf has been used. There is no handling the case where pgpass
>>> is used, but has an incorrect password.
>> Why should it? That code is complicated enough, I don't think it needs
>> to have a behavior of pretending that a wrong entry isn't there.
> In that case, we should probably teach pg_ctl about this case, no?
> Since it clearly gives an incorrect message to the user now...
>

pg_ctl decides that the server is running iff it can connect to it. Do
you intend to provide for a different test? Setting an incorrect
password for the service account sounds like pilot error to me.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-24 15:11:06
Message-ID: 25617.1285341066@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> On 09/24/2010 10:15 AM, Magnus Hagander wrote:
>> In that case, we should probably teach pg_ctl about this case, no?
>> Since it clearly gives an incorrect message to the user now...

> pg_ctl decides that the server is running iff it can connect to it. Do
> you intend to provide for a different test?

Seems like getting a password challenge from the server is sufficient
evidence that the server is running, whether we are able to meet the
challenge or not. Perhaps we could just twiddle pg_ctl's "is it up"
test a bit to notice whether the connect failure was of this sort.

(Of course, a "pg_ping" utility would be a better answer, but nobody's
gotten around to that in more than ten years, so I'm not holding my
breath.)

regards, tom lane


From: Dave Page <dpage(at)pgadmin(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-24 15:22:17
Message-ID: AANLkTik4f7VFQmQsC8SE-fbuKO5jUzsPif5KDm3tsb-z@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Fri, Sep 24, 2010 at 4:11 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> (Of course, a "pg_ping" utility would be a better answer, but nobody's
> gotten around to that in more than ten years, so I'm not holding my
> breath.)

Hmm, that sounded like it could be my 9.1 mini project - then Google
showed me that SeanC wrote something already.

http://archives.postgresql.org/pgsql-patches/2003-07/msg00053.php

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise Postgres Company


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-24 15:33:25
Message-ID: 13889.1285342405@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Dave Page <dpage(at)pgadmin(dot)org> writes:
> On Fri, Sep 24, 2010 at 4:11 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> (Of course, a "pg_ping" utility would be a better answer, but nobody's
>> gotten around to that in more than ten years, so I'm not holding my
>> breath.)

> Hmm, that sounded like it could be my 9.1 mini project - then Google
> showed me that SeanC wrote something already.
> http://archives.postgresql.org/pgsql-patches/2003-07/msg00053.php

Huh, I wonder why we never adopted that? Although I'd be inclined to
do most of the heavy lifting inside libpq, myself, and this is way
more verbose than what pg_ctl wants.

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-24 20:30:52
Message-ID: 4C9D0A7C.80400@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On 09/24/2010 11:11 AM, Tom Lane wrote:
> Andrew Dunstan<andrew(at)dunslane(dot)net> writes:
>> On 09/24/2010 10:15 AM, Magnus Hagander wrote:
>>> In that case, we should probably teach pg_ctl about this case, no?
>>> Since it clearly gives an incorrect message to the user now...
>> pg_ctl decides that the server is running iff it can connect to it. Do
>> you intend to provide for a different test?
> Seems like getting a password challenge from the server is sufficient
> evidence that the server is running, whether we are able to meet the
> challenge or not. Perhaps we could just twiddle pg_ctl's "is it up"
> test a bit to notice whether the connect failure was of this sort.

pg_ctl does in fact use that sort of logic:

if ((conn = PQconnectdb(connstr)) != NULL &&
(PQstatus(conn) == CONNECTION_OK ||
PQconnectionNeedsPassword(conn)))

But of course, libpq won't set that last condition if there is a bad
password in the pgpass file, which seems a rather perverse thing to do.

cheers

andrew


From: "Llewellyn, Mark (ADP DSI)" <mark_llewellyn(at)adp(dot)com>
To: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-27 15:27:03
Message-ID: AAB31C88839F6446AB088B532683622E29046AD2F1@DSI-GBH-MAIL1.DSI.AD.ADP.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Hi Ashesh

Yes, this appears to be the issue that the password in the pgpass.conf file for the postgres user had not been changed when the windows account password was reset.

Problem now resolved.

Many thanks
Mark Llewellyn

________________________________
From: Ashesh Vashi [mailto:ashesh(dot)vashi(at)enterprisedb(dot)com]
Sent: 17 September 2010 04:51
To: Llewellyn, Mark (ADP DSI)
Cc: pgsql-bugs(at)postgresql(dot)org; Sujeet Rajguru
Subject: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running

Hi Mark,

On of my college (Sujeet) has found a way to reproduce the same behaviour.
1. Installed PG 9.0 on Win XP SP3
2. Stop the Postgresql-9.0 service from service manager console
3. Create pgpass.conf in postgres (service account) user's profile with an incorrect password deliberately.
(Refer: http://www.postgresql.org/docs/8.4/interactive/libpq-pgpass.html)
4. Now start the postgresql-9.0 service, it will return an error and the status
shows stopped
5. However i could connect to the psql shell and get the prompt which means
the server is running.

So, please check if pgpass.conf file exists in service account (postgres) user's %APPDATA%\postgresql directory with wrong password.

--
Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise Postgres Company<http://www.enterprisedb.com>

On Thu, Sep 9, 2010 at 9:52 PM, Mark Llewellyn <mark_llewellyn(at)adp(dot)com<mailto:mark_llewellyn(at)adp(dot)com>> wrote:

The following bug has been logged online:

Bug reference: 5650
Logged by: Mark Llewellyn
Email address: mark_llewellyn(at)adp(dot)com<mailto:mark_llewellyn(at)adp(dot)com>
PostgreSQL version: 9.0 RC1
Operating system: Windows XP
Description: Postgres service showing as stopped when in fact it is
running
Details:

The postgresql-9.0 service is showing as *not running* in pgAdmin 3 1.12 RC1
and as *stopped* in the Windows services list, although the database is
actually running and I can connect to it and create databases, tables etc.
It also shows multiple postgresql tasks in Windows task manager.
However, because Windows XP is not aware that the postgresql-9.0 service is
running it is not possible to stop the service.

--
Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org<mailto:pgsql-bugs(at)postgresql(dot)org>)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system.


From: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>
To: "Llewellyn, Mark (ADP DSI)" <mark_llewellyn(at)adp(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-27 16:44:47
Message-ID: AANLkTi=Q6oHoA_S+M91_Kgp8ii7gFDg9zad=_Ogqbmv1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

We're happy to see the problem resolved on your end. :-)

--
Thanks & Regards,

Ashesh Vashi
EnterpriseDB INDIA: Enterprise Postgres Company<http://www.enterprisedb.com>

*http://www.linkedin.com/in/asheshvashi*<http://www.linkedin.com/in/asheshvashi>

On Mon, Sep 27, 2010 at 8:57 PM, Llewellyn, Mark (ADP DSI) <
mark_llewellyn(at)adp(dot)com> wrote:

> Hi Ashesh
>
>
>
> Yes, this appears to be the issue that the password in the pgpass.conf file
> for the postgres user had not been changed when the windows account password
> was reset.
>
>
>
> Problem now resolved.
>
>
>
> Many thanks
>
> Mark Llewellyn
>
>
> ------------------------------
>
> *From:* Ashesh Vashi [mailto:ashesh(dot)vashi(at)enterprisedb(dot)com]
> *Sent:* 17 September 2010 04:51
> *To:* Llewellyn, Mark (ADP DSI)
> *Cc:* pgsql-bugs(at)postgresql(dot)org; Sujeet Rajguru
> *Subject:* Re: [BUGS] BUG #5650: Postgres service showing as stopped when
> in fact it is running
>
>
>
> Hi Mark,
>
> On of my college (Sujeet) has found a way to reproduce the same behaviour.
> 1. Installed PG 9.0 on Win XP SP3
> 2. Stop the Postgresql-9.0 service from service manager console
> 3. Create pgpass.conf in postgres (service account) user's profile with an
> incorrect password deliberately.
> (Refer: http://www.postgresql.org/docs/8.4/interactive/libpq-pgpass.html)
> 4. Now start the postgresql-9.0 service, it will return an error and the
> status
> shows stopped
> 5. However i could connect to the psql shell and get the prompt which means
> the server is running.
>
> So, please check if pgpass.conf file exists in service account (postgres)
> user's %APPDATA%\postgresql directory with wrong password.
>
> --*
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: *Enterprise Postgres Company<http://www.enterprisedb.com>
>
>
>
> On Thu, Sep 9, 2010 at 9:52 PM, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>
> wrote:
>
>
> The following bug has been logged online:
>
> Bug reference: 5650
> Logged by: Mark Llewellyn
> Email address: mark_llewellyn(at)adp(dot)com
> PostgreSQL version: 9.0 RC1
> Operating system: Windows XP
> Description: Postgres service showing as stopped when in fact it is
> running
> Details:
>
> The postgresql-9.0 service is showing as *not running* in pgAdmin 3 1.12
> RC1
> and as *stopped* in the Windows services list, although the database is
> actually running and I can connect to it and create databases, tables etc.
> It also shows multiple postgresql tasks in Windows task manager.
> However, because Windows XP is not aware that the postgresql-9.0 service is
> running it is not possible to stop the service.
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>
>
>
> ------------------------------
> This message and any attachments are intended only for the use of the
> addressee and may contain information that is privileged and confidential.
> If the reader of the message is not the intended recipient or an authorized
> representative of the intended recipient, you are hereby notified that any
> dissemination of this communication is strictly prohibited. If you have
> received this communication in error, please notify us immediately by e-mail
> and delete the message and any attachments from your system.
>


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>
Cc: "Llewellyn, Mark (ADP DSI)" <mark_llewellyn(at)adp(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-09-27 17:08:45
Message-ID: AANLkTikdwTjZzjkTk8Ed-=EbP8GO9w84UyGHVTO6_Q9z@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Mon, Sep 27, 2010 at 12:44 PM, Ashesh Vashi <
ashesh(dot)vashi(at)enterprisedb(dot)com> wrote:

> We're happy to see the problem resolved on your end. :-)--
>

However, it doesn't seem that we've actually done anything about the
underlying issue with pg_ctl.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, "Llewellyn, Mark (ADP DSI)" <mark_llewellyn(at)adp(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-10-14 18:34:54
Message-ID: 201010141834.o9EIYtt00450@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Robert Haas wrote:
> On Mon, Sep 27, 2010 at 12:44 PM, Ashesh Vashi <
> ashesh(dot)vashi(at)enterprisedb(dot)com> wrote:
>
> > We're happy to see the problem resolved on your end. :-)--
> >
>
> However, it doesn't seem that we've actually done anything about the
> underlying issue with pg_ctl.

I will look at that in the next few weeks.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-12 02:49:44
Message-ID: 201011120249.oAC2niD01755@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Magnus Hagander wrote:
> On Fri, Sep 17, 2010 at 05:51, Ashesh Vashi
> <ashesh(dot)vashi(at)enterprisedb(dot)com> wrote:
> > Hi Mark,
> >
> > On of my college (Sujeet) has found a way to reproduce the same behaviour.
> > 1. Installed PG 9.0 on Win XP SP3
> > 2. Stop the Postgresql-9.0 service from service manager console
> > 3. Create pgpass.conf in postgres (service account) user's profile with an
> > incorrect password deliberately.
> > (Refer: http://www.postgresql.org/docs/8.4/interactive/libpq-pgpass.html)
> > 4. Now start the postgresql-9.0 service, it will return an error and the
> > status
> > ?? shows stopped
> > 5. However i could connect to the psql shell and get the prompt which means
> > ??? the server is running.
>
> I took a quick look at the code, and from what I can tell this is
> because PQconnectionNeedsPassword() always returns false if a
> pgpass.conf has been used. There is no handling the case where pgpass
> is used, but has an incorrect password.
>
> Does anybody recall the specific reason for this? Do we need a way for
> pg_ctl to figure this out, or do we need to change it in
> PQconnecitonNeedsPassword()?

I was not able to reproduce this failure on my BSD system using GIT
head:

$ psql test
psql: FATAL: password authentication failed for user "postgres"
password retrieved from file "/u/postgres/.pgpass"

$ pg_ctl status
pg_ctl: server is running (PID: 710)
/usr/var/local/pgsql/bin/postgres "-i"

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-12 06:20:58
Message-ID: AANLkTin=88vWWVyZhBpuLJ1VpvGFV9xJewBXVnPOq4LM@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Fri, Nov 12, 2010 at 03:49, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Magnus Hagander wrote:
>> On Fri, Sep 17, 2010 at 05:51, Ashesh Vashi
>> <ashesh(dot)vashi(at)enterprisedb(dot)com> wrote:
>> > Hi Mark,
>> >
>> > On of my college (Sujeet) has found a way to reproduce the same behaviour.
>> > 1. Installed PG 9.0 on Win XP SP3
>> > 2. Stop the Postgresql-9.0 service from service manager console
>> > 3. Create pgpass.conf in postgres (service account) user's profile with an
>> > incorrect password deliberately.
>> > (Refer: http://www.postgresql.org/docs/8.4/interactive/libpq-pgpass.html)
>> > 4. Now start the postgresql-9.0 service, it will return an error and the
>> > status
>> > ?? shows stopped
>> > 5. However i could connect to the psql shell and get the prompt which means
>> > ??? the server is running.
>>
>> I took a quick look at the code, and from what I can tell this is
>> because PQconnectionNeedsPassword() always returns false if a
>> pgpass.conf has been used. There is no handling the case where pgpass
>> is used, but has an incorrect password.
>>
>> Does anybody recall the specific reason for this? Do we need a way for
>> pg_ctl to figure this out, or do we need to change it in
>> PQconnecitonNeedsPassword()?
>
> I was not able to reproduce this failure on my BSD system using GIT
> head:
>
>        $ psql test
>        psql: FATAL:  password authentication failed for user "postgres"
>        password retrieved from file "/u/postgres/.pgpass"
>
>        $ pg_ctl status
>        pg_ctl: server is running (PID: 710)
>        /usr/var/local/pgsql/bin/postgres "-i"

The problem is not in pg_ctl status, it's in pg_ctl start. They're
different codepaths - status never tries to actually connect, it just
checks if the process is alive.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-12 14:08:45
Message-ID: 201011121408.oACE8jJ27781@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Magnus Hagander wrote:
> On Fri, Nov 12, 2010 at 03:49, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > Magnus Hagander wrote:
> >> On Fri, Sep 17, 2010 at 05:51, Ashesh Vashi
> >> <ashesh(dot)vashi(at)enterprisedb(dot)com> wrote:
> >> > Hi Mark,
> >> >
> >> > On of my college (Sujeet) has found a way to reproduce the same behaviour.
> >> > 1. Installed PG 9.0 on Win XP SP3
> >> > 2. Stop the Postgresql-9.0 service from service manager console
> >> > 3. Create pgpass.conf in postgres (service account) user's profile with an
> >> > incorrect password deliberately.
> >> > (Refer: http://www.postgresql.org/docs/8.4/interactive/libpq-pgpass.html)
> >> > 4. Now start the postgresql-9.0 service, it will return an error and the
> >> > status
> >> > ?? shows stopped
> >> > 5. However i could connect to the psql shell and get the prompt which means
> >> > ??? the server is running.
> >>
> >> I took a quick look at the code, and from what I can tell this is
> >> because PQconnectionNeedsPassword() always returns false if a
> >> pgpass.conf has been used. There is no handling the case where pgpass
> >> is used, but has an incorrect password.
> >>
> >> Does anybody recall the specific reason for this? Do we need a way for
> >> pg_ctl to figure this out, or do we need to change it in
> >> PQconnecitonNeedsPassword()?
> >
> > I was not able to reproduce this failure on my BSD system using GIT
> > head:
> >
> > ? ? ? ?$ psql test
> > ? ? ? ?psql: FATAL: ?password authentication failed for user "postgres"
> > ? ? ? ?password retrieved from file "/u/postgres/.pgpass"
> >
> > ? ? ? ?$ pg_ctl status
> > ? ? ? ?pg_ctl: server is running (PID: 710)
> > ? ? ? ?/usr/var/local/pgsql/bin/postgres "-i"
>
> The problem is not in pg_ctl status, it's in pg_ctl start. They're
> different codepaths - status never tries to actually connect, it just
> checks if the process is alive.

Uh, I still cannot reproduce the failure:

$ 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 -l /dev/null start
server starting

(Got to love that new 9.0 pgpass error message.)

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-12 15:03:26
Message-ID: 9721.1289574206@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)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.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-12 16:47:27
Message-ID: 201011121647.oACGlRF10346@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/pgpatches/pg_ctl text/x-diff 1.2 KB

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-16 11:39:35
Message-ID: AANLkTi=oUxVMeNs57movi0SPwzAWzDHA8XVQx9C3FitU@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Fri, Nov 12, 2010 at 17:47, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Tom Lane wrote:
>> Bruce Momjian <bruce(at)momjian(dot)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.

Bad Bruce, using C++ comments like that :P And non-context diff ;)

Does this actually solve the *problem*, though? The problem is not
what is reported on stdout/stderr, the problem is that the net result
is that the server is reported as not started (by the service control
manager) when it actually *is* started. In this case, stderr doesn't
even go anywhere. What happens if you *don't* Ctrl-C it?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-17 18:50:22
Message-ID: 201011171850.oAHIoM018166@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Magnus Hagander wrote:
> > 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.
>
> Bad Bruce, using C++ comments like that :P And non-context diff ;)

That comment use was to highlight that those are not for commit, but
there if people want to test.

As far as the diff, it seems git-external-diff isn't portable to
non-Linux systems; I will post a separate email on that.

> Does this actually solve the *problem*, though? The problem is not
> what is reported on stdout/stderr, the problem is that the net result
> is that the server is reported as not started (by the service control
> manager) when it actually *is* started. In this case, stderr doesn't
> even go anywhere. What happens if you *don't* Ctrl-C it?

I was just going to post on that. :-) Right now, it prints the FATAL
and keeps printing 60 times, then says not running. Should we just exit
on FATAL and output a special exit string, or say running?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-17 18:52:19
Message-ID: AANLkTikoguB88dO125RfPHzOu0vrhLc88WyGerDChhWK@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Wed, Nov 17, 2010 at 19:50, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Magnus Hagander wrote:
>> Does this actually solve the *problem*, though? The problem is not
>> what is reported  on stdout/stderr, the problem is that the net result
>> is that the server is reported as not started (by the service control
>> manager) when it actually *is* started. In this case, stderr doesn't
>> even go anywhere. What happens if you *don't* Ctrl-C it?
>
> I was just going to post on that.  :-)  Right now, it prints the FATAL
> and keeps printing 60 times, then says not running.  Should we just exit
> on FATAL and output a special exit string, or say running?

From the perspective of the service control manager, it should say
running. That might break other scenarios though, but i'm not sure - I
think we can safely say the server is running when we try to log in
and get a password failure.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-17 18:57:19
Message-ID: 201011171857.oAHIvJr19227@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Magnus Hagander wrote:
> On Wed, Nov 17, 2010 at 19:50, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > Magnus Hagander wrote:
> >> Does this actually solve the *problem*, though? The problem is not
> >> what is reported ?on stdout/stderr, the problem is that the net result
> >> is that the server is reported as not started (by the service control
> >> manager) when it actually *is* started. In this case, stderr doesn't
> >> even go anywhere. What happens if you *don't* Ctrl-C it?
> >
> > I was just going to post on that. ?:-) ?Right now, it prints the FATAL
> > and keeps printing 60 times, then says not running. ?Should we just exit
> > on FATAL and output a special exit string, or say running?
>
> >From the perspective of the service control manager, it should say
> running. That might break other scenarios though, but i'm not sure - I
> think we can safely say the server is running when we try to log in
> and get a password failure.

That was another part of the discussion. Right now we report any FATAL,
so it might be a password problem, or something else, and it seems doing
all FATALs is the best idea because it will catch any other cases like
this.

Is FATAL, in general, enough to conclude the server is running?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-17 19:07:52
Message-ID: AANLkTikB7YUtrLzZpYW_1sogTncrTc5GOTDxh8hC_mjB@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Wed, Nov 17, 2010 at 19:57, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Magnus Hagander wrote:
>> On Wed, Nov 17, 2010 at 19:50, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>> > Magnus Hagander wrote:
>> >> Does this actually solve the *problem*, though? The problem is not
>> >> what is reported ?on stdout/stderr, the problem is that the net result
>> >> is that the server is reported as not started (by the service control
>> >> manager) when it actually *is* started. In this case, stderr doesn't
>> >> even go anywhere. What happens if you *don't* Ctrl-C it?
>> >
>> > I was just going to post on that. ?:-) ?Right now, it prints the FATAL
>> > and keeps printing 60 times, then says not running. ?Should we just exit
>> > on FATAL and output a special exit string, or say running?
>>
>> >From the perspective of the service control manager, it should say
>> running. That might break other scenarios though, but i'm not sure - I
>> think we can safely say the server is running when we try to log in
>> and get a password failure.
>
> That was another part of the discussion.  Right now we report any FATAL,
> so it might be a password problem, or something else, and it seems doing
> all FATALs is the best idea because it will catch any other cases like
> this.
>
> Is FATAL, in general, enough to conclude the server is running?

No - specifically, we will send FATAL when "the database system is
starting up", which is exactly the one we want to *avoid*.

I think we should only exclude the password case. I guess we could
also do all fatal *except* <list>, but that seems more fragile.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-17 19:21:44
Message-ID: 17545.1290021704@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Magnus Hagander <magnus(at)hagander(dot)net> writes:
> On Wed, Nov 17, 2010 at 19:57, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>> Is FATAL, in general, enough to conclude the server is running?

> No - specifically, we will send FATAL when "the database system is
> starting up", which is exactly the one we want to *avoid*.

> I think we should only exclude the password case. I guess we could
> also do all fatal *except* <list>, but that seems more fragile.

I believe that the above argument is exactly backwards. What we want
here is to check the result of postmaster.c's canAcceptConnections(),
and there are only a finite number of error codes that can result from
rejections there. If we get past that, there are a large number of
possible failures, but all of them indicate that the postmaster is in
principle willing to accept connections. Checking for password errors
only is utterly wrong: any other type of auth failure would be the same
for this purpose, as would "no such database", "no such user", "too many
connections", etc etc etc.

What we actually want here, and don't have, is the fabled pg_ping
protocol...

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-17 19:47:48
Message-ID: 201011171947.oAHJlmh10273@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Tom Lane wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
> > On Wed, Nov 17, 2010 at 19:57, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> >> Is FATAL, in general, enough to conclude the server is running?
>
> > No - specifically, we will send FATAL when "the database system is
> > starting up", which is exactly the one we want to *avoid*.
>
> > I think we should only exclude the password case. I guess we could
> > also do all fatal *except* <list>, but that seems more fragile.
>
> I believe that the above argument is exactly backwards. What we want
> here is to check the result of postmaster.c's canAcceptConnections(),
> and there are only a finite number of error codes that can result from
> rejections there. If we get past that, there are a large number of
> possible failures, but all of them indicate that the postmaster is in
> principle willing to accept connections. Checking for password errors
> only is utterly wrong: any other type of auth failure would be the same
> for this purpose, as would "no such database", "no such user", "too many
> connections", etc etc etc.

Agreed. So how do we pass that info to libpq without exceeding the
value of fixing this problem? Should we parse pg_controldata output?
pg_upgrade could use machine-readable output from that too.

> What we actually want here, and don't have, is the fabled pg_ping
> protocol...

Well, we are basically figuring how to implement that with this fix,
whether it is part of pg_ctl or a separate binary.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-17 19:55:33
Message-ID: 19438.1290023733@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> Agreed. So how do we pass that info to libpq without exceeding the
> value of fixing this problem? Should we parse pg_controldata output?
> pg_upgrade could use machine-readable output from that too.

pg_controldata seems 100% unrelated to this problem. You cannot even
tell if the postmaster is alive just by inspecting pg_control.

>> What we actually want here, and don't have, is the fabled pg_ping
>> protocol...

> Well, we are basically figuring how to implement that with this fix,
> whether it is part of pg_ctl or a separate binary.

Possibly the cleanest fix is to implement pg_ping as a libpq function.
You do have to distinguish connection failures (ie connection refused)
from errors that came back from the postmaster, and the easiest place to
be doing that is inside libpq.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-17 20:03:04
Message-ID: 201011172003.oAHK34T12699@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > Agreed. So how do we pass that info to libpq without exceeding the
> > value of fixing this problem? Should we parse pg_controldata output?
> > pg_upgrade could use machine-readable output from that too.
>
> pg_controldata seems 100% unrelated to this problem. You cannot even
> tell if the postmaster is alive just by inspecting pg_control.

I was thinking of this:

$ pg_controldata /u/pg/data
...
Database cluster state: shut down

> >> What we actually want here, and don't have, is the fabled pg_ping
> >> protocol...
>
> > Well, we are basically figuring how to implement that with this fix,
> > whether it is part of pg_ctl or a separate binary.
>
> Possibly the cleanest fix is to implement pg_ping as a libpq function.
> You do have to distinguish connection failures (ie connection refused)
> from errors that came back from the postmaster, and the easiest place to
> be doing that is inside libpq.

OK, so a new libpq function --- got it. Would we just pass the status
from the backend or can it be done without backend modifications?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-17 22:23:54
Message-ID: 25379.1290032634@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> Tom Lane wrote:
>> Possibly the cleanest fix is to implement pg_ping as a libpq function.
>> You do have to distinguish connection failures (ie connection refused)
>> from errors that came back from the postmaster, and the easiest place to
>> be doing that is inside libpq.

> OK, so a new libpq function --- got it. Would we just pass the status
> from the backend or can it be done without backend modifications?

It would definitely be better to do it without backend mods, so that
the functionality would work against back-branch postmasters.

To my mind, the entire purpose of such a function is to classify the
possible errors so that the caller doesn't have to. So I wouldn't
consider that it ought to "pass back the status from the backend".
I think what we basically want is a function that takes a conninfo
string (or one of the variants of that) and returns an enum defined
more or less like this:

* failed to connect to postmaster
* connected, but postmaster is not accepting sessions
* postmaster is up and accepting sessions

I'm not sure those are exactly the categories we want, but something
close to that. In particular, I don't know if there's any value in
subdividing the "not accepting sessions" status --- pg_ctl doesn't
really care, but other use-cases might want to tell the difference
between the various canAcceptConnections failure states.

BTW, it is annoying that we can't definitively distinguish "postmaster
is not running" from a connectivity problem, but I can't see a way
around that.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-18 02:54:33
Message-ID: 201011180254.oAI2sXK17185@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > Tom Lane wrote:
> >> Possibly the cleanest fix is to implement pg_ping as a libpq function.
> >> You do have to distinguish connection failures (ie connection refused)
> >> from errors that came back from the postmaster, and the easiest place to
> >> be doing that is inside libpq.
>
> > OK, so a new libpq function --- got it. Would we just pass the status
> > from the backend or can it be done without backend modifications?
>
> It would definitely be better to do it without backend mods, so that
> the functionality would work against back-branch postmasters.
>
> To my mind, the entire purpose of such a function is to classify the
> possible errors so that the caller doesn't have to. So I wouldn't
> consider that it ought to "pass back the status from the backend".
> I think what we basically want is a function that takes a conninfo
> string (or one of the variants of that) and returns an enum defined
> more or less like this:
>
> * failed to connect to postmaster
> * connected, but postmaster is not accepting sessions
> * postmaster is up and accepting sessions
>
> I'm not sure those are exactly the categories we want, but something
> close to that. In particular, I don't know if there's any value in
> subdividing the "not accepting sessions" status --- pg_ctl doesn't
> really care, but other use-cases might want to tell the difference
> between the various canAcceptConnections failure states.
>
> BTW, it is annoying that we can't definitively distinguish "postmaster
> is not running" from a connectivity problem, but I can't see a way
> around that.

Agreed. I will research this.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-24 05:14:45
Message-ID: 201011240514.oAO5Ejd22656@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > > Tom Lane wrote:
> > >> Possibly the cleanest fix is to implement pg_ping as a libpq function.
> > >> You do have to distinguish connection failures (ie connection refused)
> > >> from errors that came back from the postmaster, and the easiest place to
> > >> be doing that is inside libpq.
> >
> > > OK, so a new libpq function --- got it. Would we just pass the status
> > > from the backend or can it be done without backend modifications?
> >
> > It would definitely be better to do it without backend mods, so that
> > the functionality would work against back-branch postmasters.
> >
> > To my mind, the entire purpose of such a function is to classify the
> > possible errors so that the caller doesn't have to. So I wouldn't
> > consider that it ought to "pass back the status from the backend".
> > I think what we basically want is a function that takes a conninfo
> > string (or one of the variants of that) and returns an enum defined
> > more or less like this:
> >
> > * failed to connect to postmaster
> > * connected, but postmaster is not accepting sessions
> > * postmaster is up and accepting sessions
> >
> > I'm not sure those are exactly the categories we want, but something
> > close to that. In particular, I don't know if there's any value in
> > subdividing the "not accepting sessions" status --- pg_ctl doesn't
> > really care, but other use-cases might want to tell the difference
> > between the various canAcceptConnections failure states.
> >
> > BTW, it is annoying that we can't definitively distinguish "postmaster
> > is not running" from a connectivity problem, but I can't see a way
> > around that.
>
> Agreed. I will research this.

I have researched this and developed the attached patch. It implements
PGping() and PGpingParams() in libpq, and has pg_ctl use it for pg_ctl
-w server status detection.

The new output for cases where .pgpass is not allowing for a connection
is:

$ pg_ctl -w -l /dev/null start
waiting for server to start.... done
server started
However, could not connect, perhaps due to invalid authentication or
misconfiguration.

The code basically checks the connection status between PQconnectStart()
and connectDBComplete() to see if the server is running but we failed to
connect for some reason.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/pgpatches/pg_ctl_v2 text/x-diff 9.2 KB

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-25 18:11:44
Message-ID: 201011251811.oAPIBiP21864@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Bruce Momjian wrote:
> > > BTW, it is annoying that we can't definitively distinguish "postmaster
> > > is not running" from a connectivity problem, but I can't see a way
> > > around that.
> >
> > Agreed. I will research this.
>
> I have researched this and developed the attached patch. It implements
> PGping() and PGpingParams() in libpq, and has pg_ctl use it for pg_ctl
> -w server status detection.
>
> The new output for cases where .pgpass is not allowing for a connection
> is:
>
> $ pg_ctl -w -l /dev/null start
> waiting for server to start.... done
> server started
> However, could not connect, perhaps due to invalid authentication or
> misconfiguration.
>
> The code basically checks the connection status between PQconnectStart()
> and connectDBComplete() to see if the server is running but we failed to
> connect for some reason.

I have applied this patch, with modified wording of the "cannot connect"
case:

$ pg_ctl -w -l /dev/null start
waiting for server to start.... done
server started
warning: could not connect, perhaps due to invalid authentication or
misconfiguration.

I assume having the warning as the last printed things is appropriate.
This is my second patch this week that got little feedback --- I am
getting a little spooked. ;-)

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-26 04:25:19
Message-ID: AANLkTikUDRJ-FdD8RJYyO+btAJfE8B6MPwryA-VJ9LwU@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Fri, Nov 26, 2010 at 3:11 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> I have applied this patch, with modified wording of the "cannot connect"
> case:
>
>        $ pg_ctl -w -l /dev/null start
>        waiting for server to start.... done
>        server started
>        warning:  could not connect, perhaps due to invalid authentication or
>        misconfiguration.

This patch breaks the behavior that "pg_ctl -w start" waits until the standby
has been ready to accept read-only queries. IOW, pg_ctl without this patch
continues to check the connection even if the connection is rejected because
the database has not been consistent yet. But pg_ctl with this patch treats
that rejection as success of the standby starting and prints the above
messages.

I agree to treat the receipt of password request from the server as success
of the server starting. But I don't think that we should treat other rejection
cases that way and change the existing behavior.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-26 19:19:51
Message-ID: 201011261919.oAQJJp504942@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Fujii Masao wrote:
> On Fri, Nov 26, 2010 at 3:11 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > I have applied this patch, with modified wording of the "cannot connect"
> > case:
> >
> > ? ? ? ?$ pg_ctl -w -l /dev/null start
> > ? ? ? ?waiting for server to start.... done
> > ? ? ? ?server started
> > ? ? ? ?warning: ?could not connect, perhaps due to invalid authentication or
> > ? ? ? ?misconfiguration.
>
> This patch breaks the behavior that "pg_ctl -w start" waits until the standby
> has been ready to accept read-only queries. IOW, pg_ctl without this patch
> continues to check the connection even if the connection is rejected because
> the database has not been consistent yet. But pg_ctl with this patch treats
> that rejection as success of the standby starting and prints the above
> messages.
>
> I agree to treat the receipt of password request from the server as success
> of the server starting. But I don't think that we should treat other rejection
> cases that way and change the existing behavior.

OK, that is easy to fix. The only downside is that if you misconfigured
.pgpass (which is what I used for testing), you have to wait 60 seconds
to get the "cannot connect" error message. Is that OK?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-26 20:26:19
Message-ID: AANLkTikgvKed1t8OF_b5ombMp9Rei0Z6z_YhfzNMN0MM@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Hey hackers,

I am sorry, but is it possible to implement BTW ability to
check exactly status of authentication from libpq ? As for now,
the only way to check failed authentication is parsing the error
message, that is sadly.

2010/11/26 Bruce Momjian <bruce(at)momjian(dot)us>

> Fujii Masao wrote:
> > On Fri, Nov 26, 2010 at 3:11 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > > I have applied this patch, with modified wording of the "cannot
> connect"
> > > case:
> > >
> > > ? ? ? ?$ pg_ctl -w -l /dev/null start
> > > ? ? ? ?waiting for server to start.... done
> > > ? ? ? ?server started
> > > ? ? ? ?warning: ?could not connect, perhaps due to invalid
> authentication or
> > > ? ? ? ?misconfiguration.
> >
> > This patch breaks the behavior that "pg_ctl -w start" waits until the
> standby
> > has been ready to accept read-only queries. IOW, pg_ctl without this
> patch
> > continues to check the connection even if the connection is rejected
> because
> > the database has not been consistent yet. But pg_ctl with this patch
> treats
> > that rejection as success of the standby starting and prints the above
> > messages.
> >
> > I agree to treat the receipt of password request from the server as
> success
> > of the server starting. But I don't think that we should treat other
> rejection
> > cases that way and change the existing behavior.
>
> OK, that is easy to fix. The only downside is that if you misconfigured
> .pgpass (which is what I used for testing), you have to wait 60 seconds
> to get the "cannot connect" error message. Is that OK?
>
> --
> Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
> EnterpriseDB http://enterprisedb.com
>
> + It's impossible for everything to be true. +
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

--
// Dmitriy.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-26 20:30:49
Message-ID: 15854.1290803449@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> Fujii Masao wrote:
>> I agree to treat the receipt of password request from the server as success
>> of the server starting. But I don't think that we should treat other rejection
>> cases that way and change the existing behavior.

> OK, that is easy to fix.

It's wrong though. If you get back a "password rejected" error, or most
other types of errors, it still indicates that the server started.
We just went over this a few days ago.

> The only downside is that if you misconfigured
> .pgpass (which is what I used for testing), you have to wait 60 seconds
> to get the "cannot connect" error message. Is that OK?

No; it's useless and unnecessary behavior.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-26 20:39:33
Message-ID: 16039.1290803973@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> Fujii Masao wrote:
>> This patch breaks the behavior that "pg_ctl -w start" waits until the standby
>> has been ready to accept read-only queries. IOW, pg_ctl without this patch
>> continues to check the connection even if the connection is rejected because
>> the database has not been consistent yet. But pg_ctl with this patch treats
>> that rejection as success of the standby starting and prints the above
>> messages.

The reason this is a problem is that somebody, in a fit of inappropriate
optimization, took out the code that allowed canAcceptConnections to
distinguish the "not consistent yet" state. We need to put that back,
not try to kluge around the problem from the client side.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-26 23:30:03
Message-ID: 5594.1290814203@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

I wrote:
> The reason this is a problem is that somebody, in a fit of inappropriate
> optimization, took out the code that allowed canAcceptConnections to
> distinguish the "not consistent yet" state.

Oh, no, that's not the case --- the PM_RECOVERY postmaster state does
still distinguish not-ready from ready. The real problem is that what
Bruce implemented has practically nothing to do with what was discussed
last week. PQping is supposed to be smarter about classifying errors
than this.

Speaking of classifying errors, should we have a fourth result value to
cover "obviously bogus parameters"? Right now you'll get PQNORESPONSE
for cases like incorrect syntax in the conninfo string. I'm not sure
how tense we ought to try to be about distinguishing, but if libpq
failed before even attempting a connection, PQNORESPONSE seems a bit
misleading.

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-27 00:16:20
Message-ID: AANLkTinfpBj9SJzvZJ9Q8YrZ-f6nDfzmaTScMZCLXNeP@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Fri, Nov 26, 2010 at 6:30 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Speaking of classifying errors, should we have a fourth result value to
> cover "obviously bogus parameters"?

+1.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-27 00:45:56
Message-ID: 201011270045.oAR0juG02568@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Tom Lane wrote:
> I wrote:
> > The reason this is a problem is that somebody, in a fit of inappropriate
> > optimization, took out the code that allowed canAcceptConnections to
> > distinguish the "not consistent yet" state.
>
> Oh, no, that's not the case --- the PM_RECOVERY postmaster state does
> still distinguish not-ready from ready. The real problem is that what
> Bruce implemented has practically nothing to do with what was discussed
> last week. PQping is supposed to be smarter about classifying errors
> than this.

I was not aware this was discussed last week because I am behind on
email. I was fixing a report from a month ago. I did explain how I was
doing the tests.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-27 06:38:46
Message-ID: 14416.1290839926@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> Tom Lane wrote:
>> PQping is supposed to be smarter about classifying errors
>> than this.

> I was not aware this was discussed last week because I am behind on
> email. I was fixing a report from a month ago. I did explain how I was
> doing the tests.

Um, you did respond in that thread, several times even:
http://archives.postgresql.org/pgsql-hackers/2010-11/msg01102.php
so I kind of assumed that the patch you presented this week did
what was agreed to last week.

I have committed a patch to make PQping do what was agreed to.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>, Mark Llewellyn <mark_llewellyn(at)adp(dot)com>, pgsql-hackers(at)postgresql(dot)org, Sujeet Rajguru <sujeet(dot)rajguru(at)enterprisedb(dot)com>
Subject: Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Date: 2010-11-27 16:10:27
Message-ID: 201011271610.oARGARs10224@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > Tom Lane wrote:
> >> PQping is supposed to be smarter about classifying errors
> >> than this.
>
> > I was not aware this was discussed last week because I am behind on
> > email. I was fixing a report from a month ago. I did explain how I was
> > doing the tests.
>
> Um, you did respond in that thread, several times even:
> http://archives.postgresql.org/pgsql-hackers/2010-11/msg01102.php
> so I kind of assumed that the patch you presented this week did
> what was agreed to last week.

Yes, I do remember that, but I remember this:

http://archives.postgresql.org/pgsql-hackers/2010-11/msg01095.php

What we want here is to check the result of postmaster.c's
canAcceptConnections(),

and this:

http://archives.postgresql.org/pgsql-hackers/2010-11/msg01106.php

You do have to distinguish connection failures (ie connection refused)
from errors that came back from the postmaster, and the easiest place to
be doing that is inside libpq.

which I thought meant it had to be done in libpq and we didn't have
access to the postmaster return codes in libpq.

Your changes look very good, and not something I would have been able to
code.

> I have committed a patch to make PQping do what was agreed to.

Thanks.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +