Serializability
Serializability is a transaction-isolation property under which the read results and writes of committed concurrent transactions are equivalent to some serial execution of those transactions.
The equivalent order need not preserve real-time precedence; strict serializability adds that constraint. This does not require executing transactions physically one at a time. PostgreSQL's Serializable mode can abort a transaction to prevent a serialization anomaly, so applications must handle retries. Neither the term nor a read option named serializable independently specifies durability. Matching final values alone is not enough to establish equivalence. Snapshot isolation can allow write skew across different rows.
PostgreSQL 18 activates DEFERRABLE only for SERIALIZABLE, READ ONLY transactions. Initial snapshot acquisition may wait; after that, the transaction avoids normal serializable monitoring overhead and cannot cause or suffer a serialization failure. This is a specific transaction mode, not a promise that arbitrary read-only transactions are serializable or that every kind of error is prevented. [6]
Ports and Grittner explain a safe snapshot as a prefix of the apparent serial order. Commit order can differ: a report may see a batch closure before an earlier-assigned insert commits. Deferral waits for snapshot safety rather than merely freezing visible rows. This is a source-based explanation of PostgreSQL SSI, not a general snapshot-backup guarantee. [7]
Relations
- related
- Linearizability, Compare-and-swap, Snapshot isolation, Write skew, Logical database backup, Sequential consistency, Strict serializability, Serializable Snapshot Isolation, Hyder, Optimistic concurrency control, Two-phase locking, FuzzyLog, HyperDex, Sinfonia
Advantages
- A PostgreSQL serializable read-only deferrable transaction can run a long report without serialization-failure retries after acquiring its snapshot. [6]
Limitations
- PostgreSQL READ ONLY restricts SQL operations; it does not prohibit all disk writes. DEFERRABLE has no effect without both SERIALIZABLE and READ ONLY. [6]
- PostgreSQL's application-consistency guarantee requires Serializable for all writes and reads needing that consistent view. Changing the exporter alone does not upgrade lower-isolation writers. [8]
Citations
- PostgreSQL 18: SET TRANSACTION, read-only access and deferrable snapshots
- Dan R. K. Ports and Kevin Grittner. Serializable Snapshot Isolation in PostgreSQL. PVLDB 5(12), 1850-1861 (2012), sections 2.1.2 and 4.2-4.3.
- PostgreSQL 18: Data Consistency Checks at the Application Level, section 13.4.1
Further reading
- Maurice P. Herlihy and Jeannette M. Wing. Linearizability: A Correctness Condition for Concurrent Objects. ACM TOPLAS 12(3), 1990, sections 2.2 and 3.3.
- PostgreSQL 18 documentation, section 13.2: Transaction Isolation.
- etcd v3.6 API guarantees: durability, strict serializability and operation completion.
- Storage consistency: ordering is not a transaction or a durability promise
- Hal Berenson et al. A Critique of ANSI SQL Isolation Levels. ACM SIGMOD 1995; MSR-TR-95-51, section 4.2.