On Sat, May 18, 2019 at 01:07:15PM -0400, Tom Lane wrote:
> I've not worked that out in any detail; getting the switches included
> properly might be too much of a pain for this to be an improvement.
> But for sure I don't want there to be multiple copies of that list of
> which subprocess types use shared memory.
Getting rid of the process list dependency would be nice.
> A variant idea is to include shared_memory_exists in what's passed down
> by the BackendParameters mechanism, and then subprocesses can adjust
> their behavior for themselves.
I actually got to think about having extra switches to control the
re-attachment of sub-processes when thinking about a solution, and I
agree that it would be much cleaner. The idea about using backend
parameters is interesting (I haven't considered it), though I feel
that this could introduce race conditions as the process startup
scheduling can cause tricky issues on Windows, so I think that this
would make the system less robust. Using a state specific to the
postmaster for the decision-making ensures a single entry point.
> In any case, the thrust of all of this is that we shouldn't touch any
> of the assertions in the shmem support files; rather, the way to fix
> it is to improve the logic in postmaster.c so that we don't call those
> functions at all in child processes that are launched before shmem
> exists.
I certainly agree with that. Those assertions are here to stay.
--
Michael