Skip site navigation (1) Skip section navigation (2)

Re: Please help me

From: Frank Seesink <frank(at)mail(dot)wvnet(dot)edu>
To: pgsql-cygwin(at)postgresql(dot)org
Subject: Re: Please help me
Date: 2004-02-19 04:37:12
Message-ID: c11ehq$rua$1@sea.gmane.org (view raw or flat)
Thread:
Lists: pgsql-cygwin
Riccardo,

The use of the postmaster.pid file is not a bug.  It's a standard 
feature in Unix server software, the purpose of which is to prevent 
users from accidentally running multiple copies of a program like 
PostgreSQL.  Imagine what would happen if you fired up the PostgreSQL 
server (postmaster), and while it was working with your precious data 
writing out the bank account number from which you were about to 
transfer a multimillion dollar transaction, you accidentally fired up a 
second copy of postmaster, which then tried to access the same database 
files, causing a deadlock and possible data corruption.  Ouch.

The postmaster.pid file is there to protect you.  When you fire up 
postmaster, postmaster first looks if a postmaster.pid file exists.  If 
postmaster.pid exists, postmaster shuts down immediately, without ever 
trying to access the database files.  If postmaster.pid does not exist, 
then postmaster generates this file (think Postmaster Process ID file), 
which simply contains the process ID number that postmaster is running 
as.  When you shutdown postmaster cleanly, it deletes this file. 
postmaster.pid acts as a switch.

In the even that postmaster dies abnormally, the postmaster.pid file is 
left behind, almost as a warning that things did not go well.  As a 
database administrator, you would then run diagnostics on your database 
files to make sure no corruption had occurred, and, once you were sure 
all was well, you simply would delete the postmaster.pid file and then 
relaunch postmaster.

Now in Windows, this is all fine and good, except that if you follow 
Jason Tishler's README on installing PostgreSQL as an NT service, it 
would often be nice if on system startup, any leftover postmaster.pid 
files were deleted before PostgreSQL started up.  For example, if 
someone accidentally powered off the Windows box, postmaster would not 
have the chance to delete the PID file, meaning on the next bootup, your 
PostgreSQL db wouldn't start.

But again, this is by design, to make sure you as admin are aware of 
what happened.  If, as in my case, you are willing to take that chance, 
then you have to take some extra steps in order to delete the PID file 
on startup.  Search through this mailing list, as I have already posted 
details on this before.

But please note that this is NOT a bug.  Odds are all you need to do is 
go to your data store (which should be /var/postgresql/data if you're 
using the latest version of PostgreSQL and followed Jason's README, or 
possibly /usr/share/postgresql/data if you're using a slightly older 
version), find the postmaster.pid file there, and delete it.  Then 
startup PostgreSQL again and you're back in business.


Riccardo Merino wrote:

> Hello to everyone,
>  
>     that's the first time I visit your site.
> I don't know if writing to this e-mail address is the right way.
> I tried to follow the history of a problem I can't solve, but I can't 
> understand if there would be a solution.
>  
> I try to explain, please let me know something or who can help me.
>  
> I installed Cygwin and Postgresql on a server running Windows 2000. When 
> I restart the server, the service postmaster doesn't start. I learned 
> that the file postmaster.pid has not been deleted and I don't know if 
> there is a patch that fix this bug
> 
> Thank you very much for all.
>  
> 
> /________________________________/
>    Riccardo Merino
> 
>      System Administrator
>      Servizio Sanità Milano
> 
>      Tel. 0221044562
>      Fax. 0221044564
> 
>  


In response to

pgsql-cygwin by date

Next:From: Richard Sydney-SmithDate: 2004-02-20 02:07:43
Subject: PID files Feature
Previous:From: Frank SeesinkDate: 2004-02-19 04:25:10
Subject: Re: Patch for text of HOWTO entitled "How to install PostgreSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group