Skip to content

Commit bcedc42

Browse files
committed
strong_consistency: improve the text.
1 parent e603c40 commit bcedc42

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

strong-consistency.md

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,44 @@ summary: CockroachDB implements consistent replication via majority consensus be
44
toc: false
55
---
66

7-
CockroachDB replicates your data multiple times and guarantees consistency between replicas
8-
using the [Raft consensus algorithm](https://raft.github.io/), a popular alternative to
9-
[Paxos](http://research.microsoft.com/en-us/um/people/lamport/pubs/paxos-simple.pdf).
10-
A consensus algorithm guarantees that any majority of replicas together can always provide
11-
the most recently written data on reads. Writes must reach a majority of replicas (2 out of
12-
3 by default) before they are considered committed. If a write does not reach a majority of
13-
replicas, it will fail, not be permanent, and will never be visible to readers. This means
14-
that clients always see serializable consistency when viewing data (i.e., stale reads are
15-
not possible).
7+
CockroachDB replicates your data multiple times and guarantees consistency between replicas.
168

9+
Key properties:
10+
11+
- CockroachDB guarantees serializable SQL transactions
12+
[as long as system clocks are synchronized with NTP](https://www.cockroachlabs.com/blog/living-without-atomic-clocks/)
1713
- No downtime for server restarts, machine failures, or datacenter outages
1814
- Local or wide-area replication with no stale reads on failover
1915
- Employs Raft, a popular successor to Paxos
2016

17+
How does this work?
18+
19+
- Stored data is versioned with MVCC, so reads simply limit
20+
their scope to the data visible at the time the read transaction started.
21+
22+
- Writes are serviced using the
23+
[Raft consensus algorithm](https://raft.github.io/), a popular
24+
alternative to
25+
[Paxos](http://research.microsoft.com/en-us/um/people/lamport/pubs/paxos-simple.pdf).
26+
A consensus algorithm guarantees that any majority of replicas
27+
together always agree on whether an update was committed
28+
successfully. Updates (writes) must reach a majority of replicas (2
29+
out of 3 by default) before they are considered committed.
30+
31+
To ensure that a write transaction does not interfere with
32+
read transactions that start after it, CockroachDB also uses
33+
a [timestamp cache](https://www.cockroachlabs.com/blog/serializable-lockless-distributed-isolation-cockroachdb/)
34+
which remembers when data was last read by ongoing transactions.
35+
36+
This ensures that clients always observe serializable consistency
37+
with regards to other concurrent transactions.
38+
2139
<img src="images/2strong-consistency.png" alt="Strong consistency in CockroachDB" style="width: 400px" />
2240

2341
## See Also
2442

43+
- [Serializable, Lockless, Distributed: Isolation in CockroachDB](https://www.cockroachlabs.com/blog/serializable-lockless-distributed-isolation-cockroachdb/)
2544
- [Consensus, Made Thrive](https://www.cockroachlabs.com/blog/consensus-made-thrive/)
2645
- [Trust, But Verify: How CockroachDB Checks Replication](https://www.cockroachlabs.com/blog/trust-but-verify-cockroachdb-checks-replication/)
46+
- [Living Without Atomic Clocks](https://www.cockroachlabs.com/blog/living-without-atomic-clocks/)
47+
- [The CockroachDB Architecture Document](https://github.com/cockroachdb/cockroach/blob/master/docs/design.md)

0 commit comments

Comments
 (0)