Andres Freund <andres@anarazel.de> writes:
> 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.
It's certainly arguable that PG_ENSURE_ERROR_CLEANUP is a special
snowflake and needs to use a separate mechanism. What is not real clear
to me is why there are any other callers that must use before_shmem_exit
rather than on_shmem_exit --- IOW, except for P_E_E_C's use, I have never
been persuaded that the former callback list should exist at all. The
expectation for on_shmem_exit is that callbacks correspond to system
service modules that are initialized in a particular order, and can safely
be torn down in the reverse order. Why can't the existing callers just
make even-later entries into that same callback list?
regards, tom lane