Consistency models
Overview
Consistency models specify which observations of distributed operations are permitted. Linearizability requires each operation to appear atomic at a point between its invocation and response, respecting real-time precedence. Eventual consistency means replicas converge if updates stop and communication and reconciliation succeed; it does not give a fixed lag bound. Read-your-writes and monotonic reads describe session guarantees.
First example
SELECT seq,node,version FROM dd_read ORDER BY seq;Observed SQLite result (rows in JSON):
[ [ 1, "A", 2 ], [ 2, "B", 1 ], [ 3, "B", 2 ]]How it works
The recorded reads of one synthetic session observe versions 2, 1, 2 for one key. The decrease from 2 to 1 violates monotonic reads. If version 2 was a completed write by that session, observing 1 afterward also violates read-your-writes. A causal model additionally preserves causal dependencies; independent writes may be observed differently. These rows alone do not establish linearizability or eventual convergence for a real system. Serializable isolation orders transactions equivalently to some serial execution; it does not by itself specify real-time precedence across distributed clients.
Practical example
WITH history AS (SELECT seq,version,LAG(version) OVER(ORDER BY seq) AS prev FROM dd_read)SELECT seq,prev,version FROM history WHERE version<prev;Observed SQLite result (rows in JSON):
[ [ 2, 2, 1 ]]Practice and mistakes
Practice: locate the regression using LAG, then explain how a session token could request a minimum version or wait. Hint 1: order by sequence. Hint 2: compare the current version with the previous one. Avoid describing eventual consistency as arbitrary permanent divergence.
PostgreSQL 17 example — NOT RUN
SHOW transaction_isolation;Expected result, not executed: "Reports session isolation; does not establish distributed consistency."