From e603c40e9c1bbe6fd25a43b4f6f0a866ad5d6d9f Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Fri, 13 Jan 2017 20:24:09 +0000 Subject: [PATCH 1/2] strong-consistency.md: wrap the paragraph. --- strong-consistency.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/strong-consistency.md b/strong-consistency.md index 559e99bdc8f..c8b2f188835 100644 --- a/strong-consistency.md +++ b/strong-consistency.md @@ -4,7 +4,15 @@ summary: CockroachDB implements consistent replication via majority consensus be toc: false --- -CockroachDB replicates your data multiple times and guarantees consistency between replicas using the [Raft consensus algorithm](https://raft.github.io/), a popular alternative to [Paxos](http://research.microsoft.com/en-us/um/people/lamport/pubs/paxos-simple.pdf). A consensus algorithm guarantees that any majority of replicas together can always provide the most recently written data on reads. Writes must reach a majority of replicas (2 out of 3 by default) before they are considered committed. If a write does not reach a majority of replicas, it will fail, not be permanent, and will never be visible to readers. This means that clients always see serializable consistency when viewing data (i.e., stale reads are not possible). +CockroachDB replicates your data multiple times and guarantees consistency between replicas +using the [Raft consensus algorithm](https://raft.github.io/), a popular alternative to +[Paxos](http://research.microsoft.com/en-us/um/people/lamport/pubs/paxos-simple.pdf). +A consensus algorithm guarantees that any majority of replicas together can always provide +the most recently written data on reads. Writes must reach a majority of replicas (2 out of +3 by default) before they are considered committed. If a write does not reach a majority of +replicas, it will fail, not be permanent, and will never be visible to readers. This means +that clients always see serializable consistency when viewing data (i.e., stale reads are +not possible). - No downtime for server restarts, machine failures, or datacenter outages - Local or wide-area replication with no stale reads on failover From f88313dedd2b4619222d918969f13ae180f9a508 Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Fri, 13 Jan 2017 20:39:22 +0000 Subject: [PATCH 2/2] strong_consistency: improve the text. --- frequently-asked-questions.md | 6 +++--- strong-consistency.md | 39 +++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/frequently-asked-questions.md b/frequently-asked-questions.md index 853286892b6..c9abfb1ef5c 100644 --- a/frequently-asked-questions.md +++ b/frequently-asked-questions.md @@ -66,9 +66,9 @@ For short-term failures, such as a server restart, CockroachDB uses Raft to cont ## How is CockroachDB strongly-consistent? -CockroachDB replicates your data multiple times and guarantees consistency between replicas using the [Raft consensus algorithm](https://raft.github.io/), a popular alternative to [Paxos](http://research.microsoft.com/en-us/um/people/lamport/pubs/paxos-simple.pdf). A consensus algorithm guarantees that any majority of replicas together can always provide the most recently written data on reads. Writes must reach a majority of replicas (2 out of 3 by default) before they are considered committed. If a write does not reach a majority of replicas, it will fail, not be permanent, and will never be visible to readers. This means that clients always see serializable consistency when viewing data (i.e., stale reads are not possible). - -For a detailed look at how we've tested CockroachDB for correctness and consistency, see [DIY Jepsen Testing of CockroachDB](https://www.cockroachlabs.com/blog/diy-jepsen-testing-cockroachdb/). +CockroachDB guarantees the SQL isolation level "serializable", the highest defined by the SQL standard. +It does so by combining the Raft consensus algorithm for writes and a custom time-based synchronization algorithms for reads. +See our description of [strong consistency](strong-consistency.html) for more details. ## Why is CockroachDB SQL? diff --git a/strong-consistency.md b/strong-consistency.md index c8b2f188835..4b750d23972 100644 --- a/strong-consistency.md +++ b/strong-consistency.md @@ -4,23 +4,44 @@ summary: CockroachDB implements consistent replication via majority consensus be toc: false --- -CockroachDB replicates your data multiple times and guarantees consistency between replicas -using the [Raft consensus algorithm](https://raft.github.io/), a popular alternative to -[Paxos](http://research.microsoft.com/en-us/um/people/lamport/pubs/paxos-simple.pdf). -A consensus algorithm guarantees that any majority of replicas together can always provide -the most recently written data on reads. Writes must reach a majority of replicas (2 out of -3 by default) before they are considered committed. If a write does not reach a majority of -replicas, it will fail, not be permanent, and will never be visible to readers. This means -that clients always see serializable consistency when viewing data (i.e., stale reads are -not possible). +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](https://www.cockroachlabs.com/blog/living-without-atomic-clocks/) - 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](https://raft.github.io/), a popular + alternative to + [Paxos](http://research.microsoft.com/en-us/um/people/lamport/pubs/paxos-simple.pdf). + 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](https://www.cockroachlabs.com/blog/serializable-lockless-distributed-isolation-cockroachdb/) + 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 +- [Serializable, Lockless, Distributed: Isolation in CockroachDB](https://www.cockroachlabs.com/blog/serializable-lockless-distributed-isolation-cockroachdb/) - [Consensus, Made Thrive](https://www.cockroachlabs.com/blog/consensus-made-thrive/) - [Trust, But Verify: How CockroachDB Checks Replication](https://www.cockroachlabs.com/blog/trust-but-verify-cockroachdb-checks-replication/) +- [Living Without Atomic Clocks](https://www.cockroachlabs.com/blog/living-without-atomic-clocks/) +- [The CockroachDB Architecture Document](https://github.com/cockroachdb/cockroach/blob/master/docs/design.md)