Exercise 2: What WAL Mode Fixes, and Why It Still Doesn't Allow Multiple Writers — Possible Solution ==================================================================== WHAT WAL MODE FIXES ------------------------------ Per this chapter, WAL mode means "readers can continue reading a consistent, slightly-older snapshot of the database while a write is in progress." It fixes the specific reader-blocking problem of traditional locking mode — readers are no longer forced to wait for an in-progress write to finish before they can read anything at all. WHETHER WAL MODE ALLOWS MULTIPLE SIMULTANEOUS WRITERS ------------------------------ No. Per this chapter's own explicit statement, "it's important to be precise about what WAL does and doesn't fix: it still allows only one writer at a time. WAL improves reader/writer concurrency — readers no longer block on a write in progress — but it does not add support for multiple simultaneous writers." WHY NOT ------------------------------ WAL mode's own mechanism is specifically about how READS interact with an in-progress WRITE — allowing readers to keep reading the unmodified main file while a write is appended separately to the WAL file. It says nothing about allowing two DIFFERENT writes to happen at the same time. Two simultaneous writers would both need to append changes, and there would be no defined way to reconcile two independent, concurrent modifications to the same database without some form of coordination between them (which is exactly the kind of machinery Postgres's own MVCC provides via row-level versioning, per postgres1-9, and which SQLite's own file-level locking approach was never designed to include). SQLite's writer lock remains exclusive specifically because resolving concurrent writes safely requires more sophisticated coordination than a simple append-and-checkpoint scheme provides — WAL mode was designed to solve the reader-blocking problem specifically, not to introduce that additional machinery. WHY THIS WORKS AS AN ANSWER ------------------------------ It states plainly and directly (per the chapter's own explicit wording) that WAL does not allow multiple writers, and explains WHY — tracing the limitation back to what WAL's own actual mechanism does and doesn't address, rather than treating it as an arbitrary restriction.