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

About a message when "pg_ctl -w start" failed

From
Tatsuhito Kasahara
Date:
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.tatsuhito@oss.ntt.co.jp


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

From
Tom Lane
Date:
Tatsuhito Kasahara <kasahara.tatsuhito@oss.ntt.co.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


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

From
Tatsuhito Kasahara
Date:
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.tatsuhito@oss.ntt.co.jp