ParentFull threadAlfeG·For transactions You should use different advisory lock tied to transaction: pg_advisory_xact_lock. This should solve problem even for sessions reuse and connection poolingView on HN