On Mon, Aug 10, 2020 at 8:46 PM Tom Lane <t...@sss.pgh.pa.us> wrote: > 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?
That split dates to the parallel query work, and there are some comments in shmem_exit() about it; see in particular the explanation in the middle where it says "Call dynamic shared memory callbacks." It seemed to me that I needed the re-entrancy behavior that is described there, but for a set of callbacks that needed to run before some of the existing callbacks and after others. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company