CSE Roadmap

Core tier · about 2 hours · 5 parts

Part 3 of 5 · 1 min read

Why writes must go through the leader, but reads need not

Allowing a write anywhere would create exactly the kind of conflicting update a single ordering point is meant to prevent.

Think of every line cook being allowed to look at their own copy of the recipe book freely, since reading causes no conflict. Only the head chef is allowed to actually write a change into any copy, since two cooks editing different copies at once could easily produce contradictory recipes.

In plain words: a read can safely be served from the leader or from any follower, since reading does not change anything and therefore cannot conflict with any other operation. A write, by contrast, is restricted to the leader specifically, so that every change has one single, unambiguous point of origin and a single, agreed order, exactly the kind of ordering the schedules and serializability material in Level 7 depends on. If writes were allowed on any follower independently, two different followers could each accept a conflicting change to the same data at the same time, with no single authority to decide which one is correct.

A worked example. A read-heavy reporting query can be directed to any follower to spread out load, while an UPDATE statement must always be sent specifically to the leader, regardless of which follower happens to be closest or least busy.

The key lines.

-- Reads: can go to the leader or any follower
SELECT * FROM books WHERE book_id = 501;
-- Writes: must go to the leader specifically
UPDATE books SET price = 24.99 WHERE book_id = 501;

Write routing (single-leader)

Write routing in single-leader replication sends every write specifically to the leader, giving every change one unambiguous point of origin, while reads can be served from the leader or any follower without risk.

Example: every line cook reading their own recipe copy freely, but only the head chef actually writing a change, mirrors single-leader replication's write routing.