Library / Blogs

8th Light Engineering Blog

Articles from the 8th Light consultancy on AI-assisted software delivery, agentic AI and software work in healthcare.

By 8th Light engineers · 8th Light · Added 2026-10-12

Open original source

All content belongs to 8th Light engineers / 8th Light. We only link to it and give credit. Report a problem

Learn this article

About 37 min left. Your work is saved as you go.

What you are about to study

8th Light wrote this to explain how they thought about a problem. You should know the basics: caching, queues and replication.

Ideas you will meet

Distributed Systems
Consensus, time, failure and the fundamentals of scale-out.

What we already know about this

Our own lessons on these ideas. Read them here before you start, so it makes sense.

  • Core Concepts: How Things Actually Work · 9 minTransactions and isolation levelsHow databases keep concurrent updates from corrupting each other, and the anomalies each isolation level allows.Read here

    What a transaction is

    A transaction groups several operations so they are treated as one unit. The classic guarantees are ACID:

    • Atomicity: all or nothing.
    • Consistency: rules (constraints) always hold afterwards.
    • Isolation: concurrent transactions do not see each other's half-done work.
    • Durability: once committed, it survives a crash.

    Isolation is the subtle one, because perfect isolation is expensive.

    What can go wrong when transactions overlap

    AnomalyWhat happens
    Dirty readYou read data another transaction has not committed (and may roll back)
    Non-repeatable readYou read a row twice and it changed in between
    Phantom readYou run the same query twice and new matching rows appear
    Lost updateTwo transactions read, then both write, and one overwrites the other

    Isolation levels

    Databases offer levels that trade safety for speed:

    LevelPreventsStill allows
    Read uncommittednothing muchdirty reads and more
    Read committed (a common default)dirty readsnon-repeatable and phantom reads
    Repeatable readdirty and non-repeatable readsphantoms (varies by database)
    Serializableall of the abovenothing, but slower or more retries

    The exact behaviour differs between databases, so read your database's documentation instead of assuming.

    Figure SDA-CORE-02-1 · Isolation levels · © forcsguy.com

    How databases implement it

    • Locks: readers and writers wait for each other. Simple, but can block and deadlock.
    • MVCC (multi-version concurrency control): each transaction sees a consistent snapshot while writers create new versions. Readers do not block writers. Used by PostgreSQL, MySQL (InnoDB) and others.

    Two mechanisms keep concurrent transactions apart. Locks make others wait; row versions let readers carry on:

    Figure SDA-CORE-02-2 · Locks versus row versions · © forcsguy.com

    A multi-version example

    Say row X holds 100 at version 1. Transaction A begins and takes a snapshot. Transaction B updates X to 150, creating version 2, and commits. A still reads 100 because its snapshot predates version 2, while a transaction started afterwards reads 150. Readers never block writers; old versions are cleaned up once no snapshot needs them.

    Practical advice

    • Keep transactions short. Long ones hold locks and snapshots and hurt everyone.
    • Prefer conditional updates (WHERE seats > 0) over read-then-write in application code.
    • Be ready to retry on serialization failures and deadlocks.
    • Across several databases or services there is no single transaction: use patterns such as sagas (later lessons).

    Real-world reading

    Open this lesson with its quiz and exercise

Go deeper on this

A path through videos, articles, other case studies and code on the same ideas as 8th Light Engineering Blog.

  1. Warm upGet the vocabulary first.

  2. WatchHow others solve the same problem, on video.

    Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)

  3. ReadEngineers explain it in their own words.

  4. See it in another companyThe same ideas, a different system.

  5. Read the codeSee how it looks when it is real.

Keep learning

Loading community…