Hi, On 2020-08-10 15:50:19 -0400, Robert Haas wrote: > On Mon, Aug 10, 2020 at 3:41 PM Tom Lane <t...@sss.pgh.pa.us> wrote: > > > What I do think we should do, after thinking about it more, > > > is discourage the casual use of before_shmem_exit() for things where > > > on_shmem_exit() or on_proc_exit() would be just as good. I think > > > that's what would avoid the most problems here. > > > > I think we're mostly in violent agreement here. The interesting > > question seems to be Andres' one about whether before_shmem_exit > > actually has any safe use except for PG_ENSURE_ERROR_CLEANUP. > > It may not, in which case perhaps we oughta rename it?
> If we could eliminate the other places where it's used, that'd be > great. That's not too clear to me, though, because of the above two > cases. I think there's two different aspects here: Having before_shmem_exit(), and having cancel_before_shmem_exit(). We could just not have the latter, and instead use a separate list for PG_ENSURE_ERROR_CLEANUP internally. With the callback for PG_ENSURE_ERROR_CLEANUP calling those from its private list. There's no other uses of cancel_before_shmem_exit afaict. I guess alternatively we at some point might just need a more complex callback system, where one can specify where in relation to another callback a callback needs to be registered etc. Greetings, Andres Freund