Minor race-condition problem during database startup

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Minor race-condition problem during database startup
Date: 2008-11-22 18:10:19
Message-ID: 29054.1227377419@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Buildfarm member pika showed an interesting transient failure yesterday:
http://www.pgbuildfarm.org/cgi-bin/show_log.pl?nm=pika&dt=2008-11-21%2012:13:06

./pg_regress --inputdir=. --dlpath=. --multibyte=SQL_ASCII --load-language=plpgsql --no-locale --temp-install=./tmp_check --top-builddir=../../.. --temp-port=55678 --schedule=./parallel_schedule --temp-config=/tmp/buildfarm-24h8Wg
============== creating temporary installation ==============
============== initializing database system ==============
============== starting postmaster ==============
running on port 55678 with pid 19223
============== creating database "regression" ==============
ERROR: could not request checkpoint because bgwriter not running
command failed: "/home/pgbuildfarm/workdir/HEAD/pgsql.3950/src/test/regress/./tmp_check/install//home/pgbuildfarm/workdir/HEAD/inst/bin/psql" -X -c "CREATE DATABASE \"regression\" TEMPLATE=template0 ENCODING='SQL_ASCII'" "postgres"
server stopped
gmake: *** [check] Error 2

What seems to have happened is that the bgwriter didn't get as far as
the first line of BackgroundWriterMain before the client backend tried
to issue a checkpoint request.

This is obviously a pretty minor issue, but it still seems worth fixing.
We could either try to make sure that BgWriterShmem->bgwriter_pid gets
set before the postmaster "opens its doors" for clients, or allow
RequestCheckpoint() to wait a little bit if needed for the bgwriter
to come ready. The latter seems like a more localized change.

Thoughts?

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2008-11-22 21:42:19 Re: Review: Hot standby
Previous Message Alvaro Herrera 2008-11-22 17:52:05 Re: HEAD build failure on win32 mingw