Strong Consistency

Warning:
CockroachDB v2.0 is no longer supported as of October 4, 2019. For more details, refer to the Release Support Policy.

CockroachDB replicates your data multiple times and guarantees consistency between replicas.

Key properties:

  • CockroachDB guarantees serializable SQL transactions as long as system clocks are synchronized with NTP
  • No downtime for server restarts, machine failures, or datacenter outages
  • Local or wide-area replication with no stale reads on failover
  • Employs Raft, a popular successor to Paxos

How does this work?

  • Stored data is versioned with MVCC, so reads simply limit their scope to the data visible at the time the read transaction started.

  • Writes are serviced using the Raft consensus algorithm, a popular alternative to Paxos. A consensus algorithm guarantees that any majority of replicas together always agree on whether an update was committed successfully. Updates (writes) must reach a majority of replicas (2 out of 3 by default) before they are considered committed.

To ensure that a write transaction does not interfere with read transactions that start after it, CockroachDB also uses a timestamp cache which remembers when data was last read by ongoing transactions.

This ensures that clients always observe serializable consistency with regards to other concurrent transactions.

Strong consistency in CockroachDB

See Also


Yes No