Company
Date Published
Author
Spencer Kimball
Word count
2269
Language
English
Hacker News points
94

Summary

In exploring the differences between Google's Spanner and CockroachDB, the emphasis lies on how these distributed databases handle time synchronization to ensure consistency. Spanner leverages atomic and GPS clocks to maintain precise time synchronization across nodes using its "TrueTime" API, which helps achieve linearizability by bounding clock offsets tightly, allowing efficient ordering of transactions. CockroachDB, inspired by Spanner, aims to achieve similar consistency without specialized hardware. Instead, it supports serializability and uses a provisional commit timestamp approach with retries to address timing uncertainties caused by clock offsets. While Spanner waits for a short interval to ensure transaction ordering, CockroachDB sometimes retries reads when encountering uncertain timestamps, which can lead to multiple read attempts but maintains the integrity of transaction ordering. The document highlights the complexity of achieving clock synchronization in distributed systems and the innovative solutions each database employs to address these challenges, noting that while Spanner provides stronger consistency guarantees, CockroachDB is designed to operate on commodity hardware with broader cloud compatibility.