Skip to catalogue

70

transaction

also ACID

Several writes that commit together or not at all. A half-saved order is a bug.

What is transaction?

A transaction groups reads and writes so they are atomic, consistent, isolated, and durable. Either every statement lands or none do. Isolation is how two requests avoid seeing each other’s half-work.

Why does transaction matter when vibe coding?

Models write “create order, then charge, then email” as three awaits. The process dies after the charge. You have money and no order. Say transaction or saga, and mean one of them.

How do you do transaction?

One database: one transaction around the invariants. More than one system: do not pretend a transaction — use an outbox or a saga. Never hold a transaction open across an HTTP call.

How do you ask a model for transaction?

Wrap (writes) in one database transaction. Commit only if all succeed. Do not call the network inside the transaction. If two systems are involved, say so and use an outbox, not a fake transaction.

What goes wrong with transaction?

`BEGIN` and a forgotten `COMMIT` on the pool, so later requests hang. Keep the scope tiny.

adjacent