Company
Date Published
Author
Matt Tracy
Word count
2357
Language
English
Hacker News points
None

Summary

CockroachDB's architecture ensures serializable isolation in distributed transactions using an optimistic, multi-version, timestamp-ordered concurrency control system. The Serializable Snapshot isolation level guarantees that transactions are recoverable and serializable by enforcing strict scheduling and disallowing any conflicting operations that could create a cyclic serializability graph. CockroachDB achieves this by using a multi-version concurrency control (MVCC) mechanism, where multiple timestamped versions of a key's value are stored, ensuring that write-read conflicts with later transactions are avoided. Additionally, a timestamp cache records read operations to prevent read-write conflicts, while write-write conflicts are managed by aborting transactions that attempt to commit out of order. Transactions are prioritized, with random priorities assigned and adjusted upon restarts to resolve conflicts deterministically. The system also includes mechanisms for dealing with abandoned transactions by using a heartbeat timestamp to identify and abort inactive transactions. CockroachDB's isolation level allows for high concurrency without a central coordinator, offering a robust solution for executing distributed ACID transactions.