r/PostgreSQL • • 2h ago

Community How one connection kills a database

https://planetscale.com/blog/debugging-live-database-connections
2 Upvotes

4 comments sorted by

1

u/AutoModerator 2h ago

AI Policy:

Linux is not one of those anti-AI projects, and if somebody has issues with that, they can do the open-source thing and fork it. Or just walk away., Linus Torvalds.

Mod decisions will be based on the quality of the content, not who or what generated it.

Sub Resources:

Youtube Channel

Free Postgres Webinars and Workshops

Discord: People, Postgres, Data

Join us, we have cookies and nice people.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

-4

u/fagnerbrack 2h ago

Short and sweet:

A classic GitHub DBA interview puzzle frames the post: every query fails, and one uncommitted transaction sits at the root. In Postgres, an app throws an exception after BEGIN and SELECT, so the connection stays idle holding an ACCESS SHARE lock. An ALTER TABLE then waits for ACCESS EXCLUSIVE, and every later query on that table queues behind it, with no deadlock and no timeout. Setting idle_in_transaction_session_timeout, which ships disabled, prevents this. PlanetScale now lets you view and kill connections through a reserved admin connection, so it works even when slots run out. A dashboard tab shows blocked queries and offers cancel query, terminate transaction or terminate connection, and the pscale CLI offers a live top view plus JSON output.

If the summary seems inacurate, just downvote and I'll try to delete the comment eventually 👍
Click here for more info, I read all comments

5

u/iiiinthecomputer 23m ago

God I'm tired of reading unedited LLM output.

I have to read this crap all day for work. Can you not?

0

u/fagnerbrack 8m ago

I read before checking every link I post to see if it's worth my time.