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

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 (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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: ready_msg_move.diff
Description: text/x-diff (1.5 KB)

Responses

pgsql-hackers by date

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

pgsql-patches by date

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

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