Re: atexit_callback can be a net negative - Mailing list pgsql-hackers

From Tom Lane
Subject Re: atexit_callback can be a net negative
Date
Msg-id 14684.1394204234@sss.pgh.pa.us
Whole thread Raw
In response to Re: atexit_callback can be a net negative  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Responses Re: atexit_callback can be a net negative  (Florian Weimer <fweimer@redhat.com>)
List pgsql-hackers
Heikki Linnakangas <hlinnakangas@vmware.com> writes:
> On 03/07/2014 04:23 PM, Florian Weimer wrote:
>> There's the PID reuse problem.  Forking twice (with a delay) could end
>> up with the same PID as MyProcPid.

> Not if the parent process is still running.

If the original parent backend is *not* still running, then running
atexit_callback in the grandchild is just as dangerous if not more so;
it could be clobbering shared-memory state belonging to some other
session that has recycled the same PGPROC.

I think Florian's right that there's a risk there, but it seems pretty
remote, and I don't see any reliable way to detect the case anyhow.
(Process start time?  Where would you get that from portably?)
It's not a reason not to do something about the much larger chance of
this happening in a direct child process, which certainly won't have a
matching PID.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: atexit_callback can be a net negative
Next
From: Florian Weimer
Date:
Subject: Re: atexit_callback can be a net negative