Briefle
LearnGlossaryPricing

Briefle words · Code & architecture

Rollback

Undoing all the changes made inside a database transaction that didn't finish.

Say it to an AI

Node + pg reserve(sku, qty) that runs SELECT … FOR UPDATE and the decrement in one transaction on a pooled client. Wrap it in try/catch/finally: ROLLBACK on any error (without letting a failed ROLLBACK mask the original error) and always release the client in finally, passing the error if the connection broke, so an OutOfStock can't leak connections. Throw UnknownSku if no row matches.

How an expert would brief the stronger version of “Stock reservation”.

See it

Try it as a puzzle →

Warehouse API function that reserves stock for an order using a pooled Postgres connection and a transaction.

Study A · the stronger one
Study B · the weaker one

Why: A's catch block undoes the half-done transaction so the row lock is released, and if that fails it keeps the error in 'broken' rather than letting it hide the original; B leaves the transaction open on the leaked connection.

Related words

  • Edge case
  • Guard clause
  • Swallowed exception
  • Fail fast
  • Side effect
  • Log level
  • Custom error class
  • instanceof check

Room 4 · Errors & edge cases

Learn “Rollback” in a five-minute lesson

Start free
AI can build almost anything. The bottleneck is saying what you want.
WordsPricingTermsPrivacyRefundsContact
© 2026 Briefle