Skip to main content

Session high-water marks

What this concept is​

A session token records the minimum prefix the session requires on its next successful read. Under a single immutable history, taking the maximum of prior and newly observed positions prevents successful reads from moving to an older prefix.

Why it matters here​

Tracking only your last write supports a narrower guarantee than tracking successful reads too. A session can observe a newer overwrite from another writer, then regress on another follower if it forgets the prefix of that read.

Concrete example​

Your write returns token 1. A later read on f1 observes x=3 at prefix 3. Merge to token 3, not token 1. Routing the next read to f2 at prefix 1 now blocks. Without merging the read token, the same session could see x change from 3 back to 1.

Common confusion / misconception​

Read-your-writes does not require the exact original value forever. A later overwrite is allowed. A high-water mark is a lower bound, not a pinned snapshot; later successful reads can include more updates. It is also not a permission to access the data.

How to use it​

After each successful write or read, merge compatible tokens by maximum position. Blocked and unavailable responses carry no new token. Keep the previous requirement while waiting or changing routes. Validate stream identity and position before comparison. The lab rejects tokens outside its known committed history; real validation and token-trust policies need a separate design.

Check yourself​

Why is taking the minimum incorrect? Can a session token guarantee that another unrelated user always sees your latest write?

Mini drill or application​

Create a three-request trace: write, read a later overwrite, then read from a slower follower. Predict it with no token, write-only token and merged read/write token. Name the availability cost of the strongest of these policies.

Read this only if stuck​

Use DDIA on reading your writes and monotonic reads, and PostgreSQL standby documentation for real replication context. Reconstruct the three-request trace before adding more reading.