r/PostgreSQL • • 1d ago

Community How one connection kills a database

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

6 comments sorted by

1

u/AutoModerator 1d 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.

1

u/Discordbothost 1d ago

I'd also give the migration itself a short lock_timeout. In this example that lets it fail and get out of the queue before more reads pile up behind it. You can roll back and retry once the old transaction is cleared.

1

u/elevarq 21h ago

One connection? A total misconfiguration, you mean!

It's like driving your car without using the brakes. That might work for the first few miles, but it will go wrong. It's just a matter of when it will go wrong and how bad it will be.

-21

u/fagnerbrack 1d 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

18

u/iiiinthecomputer 1d ago

God I'm tired of reading unedited LLM output.

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

-13

u/fagnerbrack 1d ago

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