r/programming • • 3d ago

How one connection kills a database

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

3 comments sorted by

4

u/Top-Emergency8630 2d ago

Not because of a hack, but because one unhandled exception prevented a COMMIT, kept a connection open, blocked a migration, and that migration blocked everything else.

That's not exactly true, it depends of language or framework. The problem is not the exception, is the waiting for the commit or rollback (that can be caused by other things like: slow processing, slow remote external call, etc, all inside a database transaction).

2

u/robert_7524 2d ago

Was the migration waiting on a lock held by that transaction, or did the open connection exhaust the app's pool? Those are different failure paths, even if both start with a transaction that never closes.

2

u/Bitter_Ad3906 2d ago

If you write transaction need ensure it’s correct implemented. On error need rollback. I can understand if process die and it’s keep alive, bad wrong code it’s coder issue.