Re: PostgreSQL 7.3.2 running as NT service under Windows XP - Mailing list pgsql-cygwin

From Jason Tishler
Subject Re: PostgreSQL 7.3.2 running as NT service under Windows XP
Date
Msg-id 20030523193056.GB956@tishler.net
Whole thread Raw
In response to PostgreSQL 7.3.2 running as NT service under Windows XP not always clearing PID file on restart  (Frank Seesink <frank@mail.wvnet.edu>)
List pgsql-cygwin
Frank,

On Thu, May 22, 2003 at 04:44:30PM -0400, Frank Seesink wrote:
> I'm noticing that my suggestion in the writeup I did--regarding
> deleting the postmaster.pid file on startup--isn't working properly
> all the time.  Took some investigating, but basically what I'm finding
> is that sometimes, after a Windows shutdown/start or restart, for
> reasons I'm not 100% clear on, the file
>
>     /usr/share/postgresql/data/postmaster.pid
>
> is left behind.

Just a WAG, but does this happen when there are active connections to
the database?

Anyway, did you supply the following options to cygrunsrv when you
installed postmaster as a service:

    1. --termsig INT
    2. --shutdown

Note that cygrunsrv defaults to TERM which will cause postmaster to wait
for all connections to end before terminating.

FWIW, the above cygrunsrv options have guaranteed me clean shutdowns
under 2000.

> And just as important, does this indicate that PostgreSQL is not being
> given the time it needs to clean house prior to reboot?

Most likely yes.

> I've spent the better part of my time trying to find a nice, clean,
> simple way to delete a file on Windows startup (but prior to NT
> services kicking in), and I'll be darned...it's a lot more difficult
> than I would have imagined.

Why not wrap postmaster in a shell script, /usr/local/bin/postmaster.sh?

    #!/bin/sh
    rm -f /usr/share/postgresql/data/postmaster.pid
    /usr/bin/postmaster $*

And then install postmaster.sh as the "service".

> [snip]
>
> Is cygrunsrv replying to the Windows kill signal before postmaster
> has fully shutdown?  I honestly don't know.

I don't know either.

> I know that if I manually do a 'net start postmaster' and 'net stop
> postmaster', PostgreSQL properly creates and deletes the
> postmaster.pid file without incident.

The above is another indication that maybe your cygrunsrv shutdown
parameter are not correct.

> What does it indicate if I do a simple Windows restart when the
> postmaster.pid file is still there on reboot?

Sorry, I can't parse the above -- even after multiple readings.

> And how can I be sure PostgreSQL has properly shutdown (other than
> checking /var/log/postmaster.log...which doesn't timestamp all its
> messages)?

I can only recommend checking the log file.  Even without the
timestamps, you should be able to figure out if PostgreSQL shut and
started up cleanly.  You can always start with a fresh log file to
facilitate the analysis.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

pgsql-cygwin by date:

Previous
From: Frank Seesink
Date:
Subject: Re: PostgreSQL 7.3.2 running as NT service under Windows XP not always
Next
From: Jason Tishler
Date:
Subject: Fwd: Re: PostgreSQL 7.3.2 running as NT service under Windows XP