Re: Fwd: race in pg_ctl start -w

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Fwd: race in pg_ctl start -w
Дата
Msg-id 22107.1349976592@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Fwd: race in pg_ctl start -w  (Heikki Linnakangas <hlinnaka@iki.fi>)
Ответы Re: Fwd: race in pg_ctl start -w  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Список pgsql-bugs
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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Fwd: race in pg_ctl start -w
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Fwd: race in pg_ctl start -w