Thread: CVS Head: Pg_ctl bug?

CVS Head: Pg_ctl bug?

From
"Dave Page"
Date:
I just noticed that if I don't specify a data directory either on the
command line or in $PGDATA,, pg_ctl fails silently on Windows (haven't
been able to test other platforms atm). Is this a bug or an oversight -
an error message would seem appropriate?

/D

postgres@PC30:/usr/local/pgsql$ bin/pg_ctl start
postgres@PC30:/usr/local/pgsql$ bin/pg_ctl -D data start
postmaster starting
postgres@PC30:/usr/local/pgsql$ LOG:  database system was interrupted at
2005-08-29 00:34:07 GMT Standard Time
LOG:  checkpoint record is at 0/39F218
LOG:  redo record is at 0/39F218; undo record is at 0/0; shutdown TRUE
LOG:  next transaction ID: 1478; next OID: 16392
LOG:  next MultiXactId: 1; next MultiXactOffset: 0
LOG:  database system was not properly shut down; automatic recovery in
progress
LOG:  record with zero length at 0/39F260
LOG:  redo is not required
LOG:  database system is ready
LOG:  transaction ID wrap limit is 2147484144, limited by database
"postgres"

Re: CVS Head: Pg_ctl bug?

From
Tom Lane
Date:
"Dave Page" <dpage@vale-housing.co.uk> writes:
> I just noticed that if I don't specify a data directory either on the
> command line or in $PGDATA,, pg_ctl fails silently on Windows (haven't
> been able to test other platforms atm). Is this a bug or an oversight -
> an error message would seem appropriate?

On my machine it does this:

$ bin/pg_ctl start
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.
$

Is write_stderr() broken on Windows?

            regards, tom lane

Re: CVS Head: Pg_ctl bug?

From
"Magnus Hagander"
Date:
> > I just noticed that if I don't specify a data directory=20
> either on the=20
> > command line or in $PGDATA,, pg_ctl fails silently on=20
> Windows (haven't=20
> > been able to test other platforms atm). Is this a bug or an=20
> oversight=20
> > - an error message would seem appropriate?
>=20
> On my machine it does this:
>=20
> $ bin/pg_ctl start
> pg_ctl: no database directory specified and environment=20
> variable PGDATA unset Try "pg_ctl --help" for more information.
> $
>=20
> Is write_stderr() broken on Windows?

In some cases it writes to the eventlog instead of stderr. Dave, can you
check if this is what's happening to you?

//Magnus

Re: CVS Head: Pg_ctl bug?

From
"Dave Page"
Date:
=20

> -----Original Message-----
> From: Magnus Hagander [mailto:mha@sollentuna.net]=20
> Sent: 29 August 2005 20:58
> To: Tom Lane; Dave Page
> Cc: pgsql-bugs@postgresql.org
> Subject: RE: [BUGS] CVS Head: Pg_ctl bug?=20
>=20
> > Is write_stderr() broken on Windows?
>=20
> In some cases it writes to the eventlog instead of stderr.=20
> Dave, can you
> check if this is what's happening to you?

Bah, no coffee for 2 weeks dulls the mind :-(

Yes, this is what's happening. Odd though, considering that I have:

#log_destination =3D 'stderr'

In my out-of-the-box config.

Regards, Dave.

Re: CVS Head: Pg_ctl bug?

From
Tom Lane
Date:
"Dave Page" <dpage@vale-housing.co.uk> writes:
>> In some cases it writes to the eventlog instead of stderr.

> Yes, this is what's happening. Odd though, considering that I have:
> #log_destination = 'stderr'
> In my out-of-the-box config.

pg_ctl doesn't read the config file, though.  Probably we need to
make write_stderr aware that it's running in an interactive program
rather than in the postmaster, and never use the eventlog in this context.

            regards, tom lane

Re: CVS Head: Pg_ctl bug?

From
"Magnus Hagander"
Date:
> > > Is write_stderr() broken on Windows?
> >=20
> > In some cases it writes to the eventlog instead of stderr.=20
> > Dave, can you
> > check if this is what's happening to you?
>=20
> Bah, no coffee for 2 weeks dulls the mind :-(
>=20
> Yes, this is what's happening. Odd though, considering that I have:
>=20
> #log_destination =3D 'stderr'
>=20
> In my out-of-the-box config.

This is output from pg_ctl, right? pg_ctl doesn't look at
postgresql.conf...

pg_ctl has:
    if (!isatty(fileno(stderr)))    /* Running as a service */
... write to eventlog ...


That check appears to be failing. The backend has a lot more elaborate
check (in port/backend/security.c). Perhaps we need to make that kind of
advanced check in pg_ctl as well?

Though I don't see any of this code changing lately, so I don't see why
it's failing now. Are you running it under some kind of different
environment than you used to? Any other ideas on why it would claim your
console is not a tty?

//Magnus

Re: CVS Head: Pg_ctl bug?

From
"Magnus Hagander"
Date:
> >> In some cases it writes to the eventlog instead of stderr.=20
>=20
> > Yes, this is what's happening. Odd though, considering that I have:
> > #log_destination =3D 'stderr'
> > In my out-of-the-box config.
>=20
> pg_ctl doesn't read the config file, though.  Probably we=20
> need to make write_stderr aware that it's running in an=20
> interactive program rather than in the postmaster, and never=20
> use the eventlog in this context.

It must sitll use the eventlog when called as a service control process,
otherwise any error output from pg_ctl in that scenario would go to
/dev/null...=20
There is code that attempts to check this, but it's apparantly failing.

//Magnus

Re: CVS Head: Pg_ctl bug?

From
"Dave Page"
Date:
=20

> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20
> Sent: 29 August 2005 21:12
> To: Dave Page
> Cc: Magnus Hagander; pgsql-bugs@postgresql.org
> Subject: Re: [BUGS] CVS Head: Pg_ctl bug?=20
>=20
> "Dave Page" <dpage@vale-housing.co.uk> writes:
> >> In some cases it writes to the eventlog instead of stderr.=20
>=20
> > Yes, this is what's happening. Odd though, considering that I have:
> > #log_destination =3D 'stderr'
> > In my out-of-the-box config.
>=20
> pg_ctl doesn't read the config file, though.  Probably we need to
> make write_stderr aware that it's running in an interactive program
> rather than in the postmaster, and never use the eventlog in=20
> this context.

Which makes sense given that the entire problem is that it doesn't know
where to find the config file!

/D

Re: CVS Head: Pg_ctl bug?

From
Tom Lane
Date:
"Magnus Hagander" <mha@sollentuna.net> writes:
> Though I don't see any of this code changing lately, so I don't see why
> it's failing now. Are you running it under some kind of different
> environment than you used to?

Well, are we sure that it was working for Dave before?  Maybe it's a
long-standing problem.  If you didn't happen to mistype a command you'd
not know it wasn't working.

            regards, tom lane

Re: CVS Head: Pg_ctl bug?

From
"Dave Page"
Date:
=20

> -----Original Message-----
> From: Magnus Hagander [mailto:mha@sollentuna.net]=20
> Sent: 29 August 2005 21:13
> To: Dave Page; Tom Lane
> Cc: pgsql-bugs@postgresql.org
> Subject: RE: [BUGS] CVS Head: Pg_ctl bug?=20
>=20
> Though I don't see any of this code changing lately, so I=20
> don't see why
> it's failing now. Are you running it under some kind of different
> environment than you used to? Any other ideas on why it would=20
> claim your
> console is not a tty?

The only change is a new install of msys a month or so back, so nothing
major ;-). I can't think of anything that /should/ have changed that
behaviour.

Regards, Dave

Re: CVS Head: Pg_ctl bug?

From
"Dave Page"
Date:
=20

> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20
> Sent: 29 August 2005 21:32
> To: Magnus Hagander
> Cc: Dave Page; pgsql-bugs@postgresql.org
> Subject: Re: [BUGS] CVS Head: Pg_ctl bug?=20
>=20
> "Magnus Hagander" <mha@sollentuna.net> writes:
> > Though I don't see any of this code changing lately, so I=20
> don't see why
> > it's failing now. Are you running it under some kind of different
> > environment than you used to?
>=20
> Well, are we sure that it was working for Dave before?  Maybe it's a
> long-standing problem.  If you didn't happen to mistype a=20
> command you'd
> not know it wasn't working.

I couldn't say whether it was or wasn't working before. On further
investigation though, it does seem to work from a Windows command
prompt, just not an msys console.

Regards, Dave.

Re: CVS Head: Pg_ctl bug?

From
Bruce Momjian
Date:
Dave Page wrote:
>
>
> > -----Original Message-----
> > From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> > Sent: 29 August 2005 21:32
> > To: Magnus Hagander
> > Cc: Dave Page; pgsql-bugs@postgresql.org
> > Subject: Re: [BUGS] CVS Head: Pg_ctl bug?
> >
> > "Magnus Hagander" <mha@sollentuna.net> writes:
> > > Though I don't see any of this code changing lately, so I
> > don't see why
> > > it's failing now. Are you running it under some kind of different
> > > environment than you used to?
> >
> > Well, are we sure that it was working for Dave before?  Maybe it's a
> > long-standing problem.  If you didn't happen to mistype a
> > command you'd
> > not know it wasn't working.
>
> I couldn't say whether it was or wasn't working before. On further
> investigation though, it does seem to work from a Windows command
> prompt, just not an msys console.

I assume we are OK on this item.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: CVS Head: Pg_ctl bug?

From
"Dave Page"
Date:
=20

> -----Original Message-----
> From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]=20
> Sent: 23 September 2005 20:56
> To: Dave Page
> Cc: Tom Lane; Magnus Hagander; pgsql-bugs@postgresql.org
> Subject: Re: [BUGS] CVS Head: Pg_ctl bug?
>=20
> Dave Page wrote:
> >=20=20
> >=20
> > > -----Original Message-----
> > > From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20
> > > Sent: 29 August 2005 21:32
> > > To: Magnus Hagander
> > > Cc: Dave Page; pgsql-bugs@postgresql.org
> > > Subject: Re: [BUGS] CVS Head: Pg_ctl bug?=20
> > >=20
> > > "Magnus Hagander" <mha@sollentuna.net> writes:
> > > > Though I don't see any of this code changing lately, so I=20
> > > don't see why
> > > > it's failing now. Are you running it under some kind of=20
> different
> > > > environment than you used to?
> > >=20
> > > Well, are we sure that it was working for Dave before?=20=20
> Maybe it's a
> > > long-standing problem.  If you didn't happen to mistype a=20
> > > command you'd
> > > not know it wasn't working.
> >=20
> > I couldn't say whether it was or wasn't working before. On further
> > investigation though, it does seem to work from a Windows command
> > prompt, just not an msys console.
>=20
> I assume we are OK on this item.

Yeah, I think so.

Regards, Dave.