The Developer Publishing Hub
One platform to write, cross-post to Dev.to, Medium, WordPress, Hashnode, and Bluesky, and protect your SEO with canonical links. Zero paywalls and full content ownership.
Markdown supported · ⌘↵ to post
Your long-transaction section is a useful reminder that an apparently idle client can still hold back cleanup. A read-only first check is:
SELECT pid, usename, application_name, state,
now() - xact_start AS transaction_age,
wait_event_type, wait_event, left(query, 160) AS query
FROM pg_stat_activity
WHERE xact_start IS NOT NULL
ORDER BY xact_start;
A role may need pg_read_all_stats to see other sessions’ query text. I would review the owning application before terminating any session. Disclosure: I’m affiliated with SqlOtter; its SQL Editor can run this check against the target PostgreSQL connection.
Jesse M. Hoffer
The fencing token point is the part people often skip. SKIP LOCKED solves claiming, but lease expiry is where duplicate side effects can sneak back in, so pairing attempts with complete() is a neat way to close that hole without extra machinery.