Skip to main content

Receipt versus visible prefixes

What this concept is​

A replica can possess log bytes without having made their effects visible. This model tracks received and applied positions separately. Each is a contiguous prefix length, not a count of arbitrary messages. The invariant is 0 <= applied <= received <= committed leader length.

Why it matters here​

Routing a read using received position can return stale state while claiming the requested update is present. A progress metric must refer to the stage whose guarantee the caller needs. Receipt, persistence and visibility are separate questions in real systems.

Concrete example​

The leader history is x=1 at position 1, y=2 at 2, x=3 at 3. Follower f1 has received 3 but applied 1. An unguarded read of x returns 1. A read requiring position 3 must be blocked even though every log entry has arrived. After apply(f1,3), x is 3 and y is 2.

Common confusion / misconception​

Position 3 means the whole first three entries, not that entry 3 arrived out of order. This model does not handle gaps. Likewise, a “synchronous” label alone does not identify the acknowledgment stage or every replica covered by it.

How to use it​

Draw received and applied positions at each explicit event. Validate monotonic transitions and prohibit applying beyond receipt. Return the applied position actually used by the read. Do not return the current leader position as a decorative freshness token: that could make the next request demand progress the session never observed.

Check yourself​

What can a follower answer at prefix zero? How does a successful missing-key result differ from a request blocked by lag?

Mini drill or application​

Move receipt to 3 while leaving apply at 0. Predict reads for x and missing with token 0 and token 1. Then advance apply once and explain each changed result.

Read this only if stuck​

Use DDIA on replication lag and PostgreSQL synchronous_commit for a concrete distinction among remote write, durable flush and remote apply. These are source-system settings, not API modes in this simulator.