Skip to content
mentoor

Transactions and concurrency

For engineers

Transactions, isolation levels, locks and idempotent writes, and the race conditions AI-written data code often misses

See where you stand

110 questions across four stages: Understand, Apply, Solve and Judge.

Try 5 questions

Practice items, not counted towards your mastery. No account needed.

Check yourself · 1 of 5

What does atomicity guarantee for a transaction?

Choose one answer

Check yourself · 2 of 5

What is PostgreSQL's default isolation level?

Choose one answer

Check yourself · 3 of 5

Which code shape is a read-modify-write race?

Choose one answer

Check yourself · 4 of 5

What happens when a second transaction updates a row that another open transaction has already updated?

Choose one answer

Check yourself · 5 of 5

What does it mean for a payment endpoint to be idempotent?

Choose one answer

Topics

  1. Drawing transaction boundaries correctly5 min read · What atomicity guarantees, which writes belong in one transaction, and why calling an external API or a model inside one holds locks too long
  2. Isolation levels and the anomalies they allow5 min read · Read committed, repeatable read and serializable in PostgreSQL, lost updates, write skew, and serialization failures that must be retried
  3. Race conditions in AI-written data code5 min read · Read-modify-write counters, check-then-insert duplicates and balance updates that pass single-user tests but break under concurrent requests
  4. Row locks, deadlocks and lock timeouts5 min read · How row and table locks queue, reading pg_locks and deadlock logs, consistent lock ordering, and lock_timeout to fail fast
  5. Idempotent writes and safe retries5 min read · Idempotency keys, upserts with ON CONFLICT, the transactional outbox, and retries that never double-charge or double-send

Start here

Helps to know first

110 questions · last verified 2026-12