Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Make sure each datastore has a clear owner, and access it via that API rather than directly. If you really must share a datastore, use a schema registry. Sharing between multiple applications doesn't really work for SQL database either (e.g. if you have multiple applications writing to your database in transactions then you're virtually guaranteed to get deadlocks).


> (e.g. if you have multiple applications writing to your database in transactions then you're virtually guaranteed to get deadlocks).

That assumption is only true if the DB is continually used by different applications. The reality is more likely a large number of applications used by a relatively small set of users, so most of the time there won't be any application writing, and it would be extremely rare for multiple applications to write at the same time.


Are rare deadlocks better than frequent ones? That sounds like a good way to not know you have problems.


This only works in theory.

In reality sometimes access via an API is way too slow or is lacking flexibility.

And I don't get this: "(e.g. if you have multiple applications writing to your database in transactions then you're virtually guaranteed to get deadlocks)"

Isn't this why transactions exist in the first place?


depends on what level of isolation and how it's done, MVCC avoids deadlocks, but if you manually lock any row/table, you can still run into deadlocks. but the DBMS' transaction manager will notice and timeout one of the transactions, failing it.

While MVCC avoids deadlocks, you'll still get a lot of failed transactions if they all operate on the same data at the same time, which you'll have to retry, but I'll take that over data inconsistency


Quite often you have several applications that look up each other's data, but mostly write to their own tables.

(But indeed, with uncoordinated development, deadlocks can occur. Still better than data corruption.)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: