Sitemap
Level Up Coding

Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev

Member-only story

PostgreSQL Said “Committed.” 234 Orders Were Gone After the Crash.

14 min read6 hours ago

--

Press enter or click to view image in full size
Acknowledged, Not Yet Durable

Your app sends COMMIT.

PostgreSQL replies with success.

Your code tells the customer their order is confirmed.

One second later, the server crashes.

Is the order still there?

Most backend developers would say yes. That is what the D in ACID means. Durability: committed data survives a crash.

So this test checks that promise directly. It kills PostgreSQL in the middle of real writes, over and over, then compares what the database told the client with what the database still has.

The answer depends on one setting. And the lost orders are not the most dangerous result.

The setup is small, and you can repeat it on a laptop:

  • PostgreSQL 16.15 in a throwaway test database
  • 4 writers creating orders as fast as they can
  • Each order is one transaction that writes to two tables, orders and payments
  • An order counts as confirmed only after commit() returns to the client
  • After 3 to 6 seconds, every PostgreSQL process is…

--

--