Transactions & Isolation
Group changes into atomic transactions and choose isolation levels and locking so that concurrent reads and writes stay correct.
4 objectives 6 steps about 130 min
Learn it step by step
Read the lessons in order, try the practice checks, then prove the skill with the knowledge check.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Explain atomicity, consistency, isolation and durability, and use BEGIN, COMMIT, ROLLBACK and savepoints to make multi-statement changes atomic.
- Reproduce non-repeatable reads, phantoms, lost updates and write skew, and state which PostgreSQL isolation level prevents each one.
- Prevent lost updates with row locks (SELECT ... FOR UPDATE), optimistic version checks, or SERIALIZABLE with retry on serialization failure.
- Diagnose lock waits and deadlocks with pg_stat_activity and pg_locks, and restructure transactions to avoid them.
Lesson plan
6 steps, about 130 min · 5 of 5 lessons available so far
- ACID and Where a Transaction Begins and Ends Concept · 20 min
- How MVCC Gives Each Transaction Its Own Snapshot Concept · 20 min
- Lab: Two Sessions, Four Anomalies Lab · 30 min
- Stopping Lost Updates: Locks, Versions, Serializable Retries Worked example · 25 min
- Finding Blockers and Untangling Deadlocks Lab · 20 min
- Check: Pick the Concurrency Strategy Knowledge check · 8 questions
Practise it
Write a script that runs two concurrent money-transfer workers against PostgreSQL; demonstrate a lost update under READ COMMITTED, fix it twice (row locks, then SERIALIZABLE with retry) and show that total balance is unchanged after 1,000 concurrent transfers.
Build it from scratch
Practice builds that exercise this skill by re-creating a real technology.
- Build your own DatabaseAdvanced · 30–60 h
References
Hard prerequisites
Unlocks
Nothing depends on this skill yet.
On these roadmaps
Progress and evidence for this skill are shared across all of them.