From: Tom Lane <tgl@sss.pgh.pa.us>
To: hlinnaka@iki.fi
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Cc: Dave Vitek <dvitek@grammatech.com>
Subject: Re: Fwd: race in pg_ctl start -w
Date: Thu, 11 Oct 2012 13:29:52 -0400
Message-ID: <22107.1349976592@sss.pgh.pa.us> (raw)
In-Reply-To: <5076FF23.6020704@iki.fi>
References: <5076F626.2090404@grammatech.com>
<5076FF23.6020704@iki.fi>
Heikki Linnakangas <hlinnaka@iki.fi> writes:
> A straightforward fix would be to just allocate one large-enough buffer
> to begin with, e.g 8k, and read the whole file in one go. I'll write up
> a patch for that.
This makes the readfile function very usage-specific though. The fix
I was thinking about was to modify the second loop to force it to fall
out once the predetermined number of lines had been read.
Or maybe we should use just one loop with realloc, instead of reading
the file twice.
>> It also flagged a very similar issue (looks like the code was copied &
>> pasted) in initdb.c. I haven't looked into whether that one is as
>> likely to be subject to a race as the pg_ctl one, but it could be
>> problematic as well.
> I don't think it's a problem for initdb, because the files that it reads
> should not change on the fly. Nevertheless, I guess we might as well add
> a check there.
Yeah, I would prefer to keep the code the same in initdb and pg_ctl,
just because somebody is likely to copy one or the other in future.
The fixed-size-buffer solution does not work for initdb.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, hlinnaka@iki.fi, dvitek@grammatech.com
Subject: Re: Fwd: race in pg_ctl start -w
In-Reply-To: <22107.1349976592@sss.pgh.pa.us>
References: <5076F626.2090404@grammatech.com> <5076FF23.6020704@iki.fi> <22107.1349976592@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox