For decades, systems engineers faced an agonizing trade-off between traditional Relational DBMSs (PostgreSQL, MySQL: strong ACID transactions and complex joins, but limited to a single physical machine or read-only replicas) and NoSQL stores (Cassandra, DynamoDB: horizontal scaling across hundreds of nodes, but sacrificing cross-row transactions, secondary indexes, and strong consistency).

Distributed SQL (NewSQL) resolves this dilemma. Systems like Google Spanner, TiDB/TiKV, and CockroachDB deliver the best of both worlds: standard SQL queries and serializable ACID transactions across arbitrary multi-node clusters, combined with automated horizontal sharding and multi-region replication.

This architectural breakthrough relies on layering: a stateless SQL parsing and distributed query execution tier decoupled from a distributed key-value storage engine partitioned into thousands of independent Multi-Raft consensus ranges, coordinated via distributed Two-Phase Commit (2PC) and synchronized or logical time horizons.

What you will learn

  • Deconstruct Multi-Raft consensus architectures: range splitting, leader balancing, and independent replica groups
  • Analyze Google Spanner TrueTime API and prove how commit wait guarantees external consistency (Linearizable ACID transactions)
  • Trace distributed Two-Phase Commit (2PC) over Multi-Raft consensus groups in TiDB/TiKV and CockroachDB
  • Implement Percolator-style distributed transactions with primary locks, secondary commits, and lock cleanup
  • Diagnose distributed deadlocks, range split thrashing, and cross-region cross-range transaction aborts
STAGE TOPICS

Topics in this chapter