Andres Freund <and...@anarazel.de> writes: > But right now I'm not seeing what prevents us from throwing a FATAL error > while holding an lwlock?
If we're inside a transaction, then ShutdownPostgres -> AbortOutOfAnyTransaction would release LWLocks. I wonder though if an exiting walsender would always take that path. Maybe it'd be good if we released all LWLocks even if we don't think we're in a transaction? More generally, it wasn't obvious to me why you thought that BaseInit was a good spot to place the on_shmem_exit call. It obviously can't be *before* that because of the pgstats dependency, but maybe it should be later? regards, tom lane