From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi> |
Cc: | pgsql-committers(at)postgresql(dot)org |
Subject: | Re: pgsql: Fix race condition in pg_ctl reading postmaster.pid. |
Date: | 2012-10-15 14:05:39 |
Message-ID: | 8435.1350309939@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi> writes:
> Fix race condition in pg_ctl reading postmaster.pid.
> If postmaster changed postmaster.pid while pg_ctl was reading it, pg_ctl
> could overrun the buffer it allocated for the file. Fix by reading the
> whole file to memory with one read() call.
Maybe I'm just not awake enough, but that code doesn't look to me like
it does the right thing with a non-newline-terminated file. Doesn't it
drop the last character of the last line?
Given the way that pg_ctl uses the file, I think that the old logic of
"pretend the file ends with a newline" is wrong anyway. If we do manage
to see an intermediate state of the file, it would be better to not
return the last line at all than to return a truncated (a/k/a wrong)
value for that line. So I'd vote to rejigger the logic to ignore any
data after the last newline.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2012-10-15 14:33:00 | Re: pgsql: Fix race condition in pg_ctl reading postmaster.pid. |
Previous Message | Heikki Linnakangas | 2012-10-15 10:01:50 | pgsql: Fix typo in comment. |