Re: [PATCHES] Fix "database is ready" race condition

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Markus Schiltknecht <markus(at)bluegap(dot)ch>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [PATCHES] Fix "database is ready" race condition
Date: 2007-02-04 19:15:18
Message-ID: 22185.1170616518@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Markus Schiltknecht <markus(at)bluegap(dot)ch> writes:
> is there a good reason to print the "database system is ready" message
> in StartupXLOG() in xact.c? It has a) nothing to do with xlog and b)
> opens a small race condition: the message gets printed, while it still
> take some CPU cycles until the postmaster really gets the SIGCHLD signal
> and sets StartupPID = 0. If you (or rather: an automated test program)
> try to connect within this timespan, you get a "database is starting up"
> error, which clearly contradicts the "is ready" message.

I don't think there's any compelling reason for having that log message
in its current form. What about redefining it to mean "postmaster is
ready to accept connections" --- either with that wording, or keeping
the old wording? Then we could just put it in one place in postmaster.c
and be done. I think your proposed patch is overcomplicated by trying
to have it still come out in bootstrap/standalone cases. For a
standalone backend, getting a prompt is what tells you it's ready ;-)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeremy Drake 2007-02-04 21:00:12 Re: [HACKERS] writing new regexp functions
Previous Message Theo Schlossnagle 2007-02-04 19:04:27 Re: Proposal: Commit timestamp

Browse pgsql-patches by date

  From Date Subject
Next Message Jeremy Drake 2007-02-04 21:00:12 Re: [HACKERS] writing new regexp functions
Previous Message Tom Lane 2007-02-04 18:23:29 Re: [pgsql-patches] Recalculating OldestXmin in a long-running vacuum