Deep dive into resource manager, error and interrupt handling.
summary
PostgreSQL’s ResourceOwner API (ResourceOwnerCreate, ResourceOwnerRemember/Forget, ResourceOwnerRelease/Delete) tracks hundreds of ephemeral objects — a single CREATE TABLE can allocate 200–300+ resources — and releases them in three phases (before locks, locks, after locks) with per-type priorities and per-type release callbacks. Error reporting builds an ErrorData then transfers control via sigsetjmp/siglongjmp so ERROR aborts a transaction, FATAL exits a session, PANIC aborts the cluster; START_CRIT_SECTION/END_CRIT_SECTION forces PANIC on failure to ensure WAL-before-data. Interrupt handlers set flags in signal handlers and run CHECK_FOR_INTERRUPTS at safe points. The code duplicates cleanup across process types and proposes a unified sigsetjmp top-level cleanup with process-specific callbacks and flags.
AI-written summary · about
