Re: About a message when "pg_ctl -w start" failed

Lists: pgsql-hackers
From: Tatsuhito Kasahara <kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: About a message when "pg_ctl -w start" failed
Date: 2008-08-21 12:44:27
Message-ID: 48AD632B.2020709@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi.

When we perform "pg_ctl -w start", postgres try to connect to
postgres-database until timeout.

If a user who perform "pg_ctl -w start" does not have authority to connect
postgres-database, pg_ctl will return 1 and show "could not start server" message.
But, in fact server is already starting. Therefore, users sometimes confuse.

I think that if we failed on test_postmaster_connection(), pg_ctl might
want to return 0 and show the message like following...
"server starting, but could not connect server. Check your authority."

Your thoughts?

Best regards.
--
Tatsuhito Kasahara
kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tatsuhito Kasahara <kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: About a message when "pg_ctl -w start" failed
Date: 2008-08-21 14:08:33
Message-ID: 23122.1219327713@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tatsuhito Kasahara <kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp> writes:
> If a user who perform "pg_ctl -w start" does not have authority to connect
> postgres-database, pg_ctl will return 1 and show "could not start server" message.

pg_ctl is already set up to recognize bad-password errors as meaning the
postmaster is up. You didn't say what auth method you are using, but
I'd think the right fix is to make it recognize other types of
authentication failures as well.

regards, tom lane


From: Tatsuhito Kasahara <kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: About a message when "pg_ctl -w start" failed
Date: 2008-08-22 05:27:35
Message-ID: 48AE4E47.7040703@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi, thanks for your reply.

Tom Lane wrote:
>> If a user who perform "pg_ctl -w start" does not have authority to connect
>> postgres-database, pg_ctl will return 1 and show "could not start server" message.
>
> You didn't say what auth method you are using
The problem that I showed occurs in following case for example.

1. user_1$ initdb -D /tmp/test
2. user_1$ sudo chown -R user_2:user_2 /tmp/test
3. user_2$ pg_ctl -D /tmp/test -w start <-- problem occurs!
(Because, there is no role for user_2 in "/tmp/test". But server starting.)

> I'd think the right fix is to make it recognize other types of
> authentication failures as well.
Yes, I agree.
I think role and database(postgres) existence check is necessary before
starting postmaster.
# Or improve the connection test way in test_postmaster_connection().

Best regards,
--
Tatsuhito Kasahara
kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp