Fix "database is ready" race condition

From: Markus Schiltknecht <markus(at)bluegap(dot)ch>
To: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Fix "database is ready" race condition
Date: 2007-02-03 16:08:26
Message-ID: 45C4B37A.5070909@bluegap.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Hi,

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 admit this is not a real issue in the common case and only matters in
automated testing or some such. But in case this does not break
anything... (ereport is used in the reaper, so I guess it's fine to use
that in signal handlers). I'm not sure if the message is needed at all
in BS_XLOG_BOOTSTRAP mode. Probably it should better say something
different.

Patch attached.

Regards

Markus

Attachment Content-Type Size
ready_msg_move.diff text/x-diff 1.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2007-02-03 16:52:29 Re: \copy (query) delimiter syntax error
Previous Message Simon Riggs 2007-02-03 09:57:46 Re: Referential Integrity and SHARE locks

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2007-02-03 16:52:29 Re: \copy (query) delimiter syntax error
Previous Message Heikki Linnakangas 2007-02-03 15:57:39 Re: [pgsql-patches] Recalculating OldestXmin in a long-running vacuum