cockroachdb/cockroach
Lore
A timeline of what shaped the CockroachDB codebase. Dates are derived from git history (first commit, tag dates, and earliest commits inside relevant directories). Where a "why" is uncertain it is hedged accordingly.
Eras
The Spencer Kimball era — Feb 2014 to ~2015
The first commit (2014-02-05, by Spencer Kimball) introduced a project named after a creature that "scales horizontally and survives". The original design doc (docs/design.md) is still in-tree. The very first cut was already aiming at a Spanner-style architecture: a single sorted KV map, ranges replicated by Raft, snapshot isolation by default. Most of the foundational packages (pkg/kv, pkg/storage, pkg/util, pkg/gossip) date from this period.
About 1,344 commits landed in 2014 and another 5,848 in 2015 as the team grew toward beta.
The first-stable rush — 2016 to mid-2017
By 2016 the project had a SQL layer, distributed transactions, and the original RocksDB-backed engine. The v1.0 release was tagged in 2017. Activity climbed to ~9,000–10,000 commits/year and the team expanded substantially.
Distributed SQL and the optimizer — 2017 to 2019
pkg/sql/distsql* and pkg/sql/flowinfra/ show how SQL execution went from a single-node row engine to a distributed flow of processors. The cost-based optimizer in pkg/sql/opt/ was built on top, replacing the original heuristic planner for most query shapes. The columnar/vectorized engine (pkg/sql/colexec/, pkg/sql/colflow/) followed shortly after as a way to compete on analytical workloads.
The Pebble migration — ~2019 to 2020
CockroachDB replaced its RocksDB engine with Pebble, a native Go LSM-tree maintained by the storage team. The transition is visible across pkg/storage/pebble*.go and pkg/storage/min_version.go, which now ratchets Pebble's "format major version" alongside the cluster version.
The multi-region and serverless build-out — 2020 to 2022
Three large initiatives reshaped large parts of the tree:
- Multi-region SQL (
pkg/ccl/multiregionccl/,pkg/sql/catalog/multiregion/,pkg/sql/alter_table_locality.go) — REGIONAL BY ROW, ZONE, GLOBAL tables, regional survivability. - Multi-tenancy (
pkg/multitenant/,pkg/ccl/multitenantccl/,pkg/server/server_controller*.go) — many SQL servers can share a host KV layer, eventually enabling CockroachDB Serverless. - Span configurations (
pkg/spanconfig/) — zone configs were rewritten as a span-keyed reconciliation system that scales with the table count.
The schema changer rewrite — 2022 to today
A "declarative" schema changer (pkg/sql/schemachanger/) is gradually replacing the legacy schema-changer. As of pkg/sql/794d7ae (Apr 2026), an in-tree document explicitly contrasts the legacy and type-schema-changer architectures while both still co-exist. Both implementations live in-tree.
Store-liveness leases and disaggregated storage — 2023 to today
Two long-running modernizations dominate recent commits:
- Store-liveness leases (
pkg/kv/kvserver/storeliveness/,pkg/raft/raftstoreliveness/) — a new leadership/lease primitive that decouples leader elections from node liveness gossip, replacing epoch-based leases. - Disaggregated storage (
pkg/storage/shared_storage.go,pkg/storage/external_sst_reader.go,pkg/cloud/) — pushing Pebble-managed L5/L6 SSTs into shared object storage, primarily to reduce inter-AZ replication cost.
Cross-cluster replication — 2023 to today
The pkg/crosscluster/ and pkg/ccl/streamingccl/-family code grew into a complete logical and physical replication offering: PCR (physical cluster replication) and LDR (logical data replication) both run as long-lived jobs that read rangefeeds out of one cluster and ingest them into another.
Longest-standing code
pkg/kv/doc.go,pkg/storage/doc.go— both carry 2014 copyright headers and describe APIs that, while heavily evolved, still exist.pkg/util/hlc/— Hybrid Logical Clocks were one of the earliest contributions and remain the cluster's time primitive.pkg/gossip/— the gossip network has survived essentially every era; its shape is mostly unchanged.pkg/raft/(formerly imported from etcd) — first imported in 2015, then forked in-tree to support epoch leases, store liveness, and per-replica term caches. The fork still includes the originalLICENSEandREADME.md.
Deprecated and removed features
- RocksDB engine — replaced by Pebble. References in old comments still mention RocksDB; the engine code is gone.
PROTECTED_TIMESTAMPv1 — superseded by thepkg/protectedts/-style implementation; old job records may still appear in mixed-version clusters.- Epoch-based leases are being phased out in favor of store-liveness leases (
pkg/kv/kvserver/replica_store_liveness.go). - Old jobs adoption protocol — comments in
pkg/jobs/registry.goandpkg/jobs/adopt.goreference an older claim/lease model that has been rebuilt aroundsqllivenesssessions. - The legacy schema changer lives next to its replacement; tables that touch many subsystems still occasionally fall back to it.
Major rewrites
| What | When | What replaced it |
|---|---|---|
| RocksDB engine | ~2019–2020 | Pebble in pkg/storage/pebble.go |
| Heuristic planner | 2017–2019 | Cost-based optimizer in pkg/sql/opt/ |
| Row-only execution | 2018–2020 | Vectorized engine in pkg/sql/colexec/, pkg/sql/colflow/ |
| Zone-config dispatch | 2021–2022 | pkg/spanconfig/ reconciler |
| Legacy schema changer | 2022–today | pkg/sql/schemachanger/ (declarative) |
| Epoch leases | 2023–today | pkg/kv/kvserver/leases/ + store-liveness |
| Single-tenant server | 2021–today | Multi-tenant pkg/server/server_controller*.go |
Growth trajectory
Commits per year on master:
2014: 1,344 2018: 10,477 2022: 11,480
2015: 5,848 2019: 8,020 2023: 12,488
2016: 9,697 2020: 10,685 2024: 11,380
2017: 9,142 2021: 10,958 2025: 11,254
2026: 4,910 (partial)The codebase has roughly tripled in size since 2017, but the commit cadence has been remarkably steady at ~10–12k commits/year. pkg/cmd/ and pkg/ui/ grew along with the operational and observability story; pkg/ccl/ grew with every CSL feature added.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.