How cockroachdb/cockroach works
CockroachDB is a distributed SQL database: clients submit SQL, which is executed through transactional coordination and a strongly consistent, replicated key-value storage layer. The repository also supports data lifecycle workflows including backup and restore, changefeeds, and cross-cluster replication, with cloud storage integrations and job tracking. The README establishes the product workflow and core capabilities; sampled source confirms selected transaction, Raft, storage, changefeed, cloud-storage, replication, and job behavior. Other subsystem links use documented capabilities and tree paths, not inspected implementation details.
Main entry points: sql SQL execution · replica_raftstorage.go KV replicas · external_storage.go External storage API · txn_interceptor_pipeliner.go Transaction pipelining
Components 16
SQL interface
- SQL execution
pkg/sql - Built-in SQL client
pkg/cli/sql_client.go
Distributed transactions
- Transaction pipelining
pkg/kv/kvclient/kvcoord/txn_interceptor_pipeliner.go - KV replicas
pkg/kv/kvserver/replica_raftstorage.go - Raft consensus
pkg/raft/storage.go
Replicated storage
- MVCC engine
pkg/storage/engine.go
Data lifecycle
- Backup and restore
pkg/backup - Changefeeds
pkg/ccl/changefeedccl - Cloud sink
pkg/ccl/changefeedccl/sink_cloudstorage.go - Stream ingestion
pkg/crosscluster/physical/stream_ingest_manager.go
Operations and integrations
- Job tracking
pkg/jobs/job_info_storage.go - External storage API
pkg/cloud/external_storage.go - Amazon S3
pkg/cloud/amazon/s3_storage.go - Tenant server lifecycle
pkg/server/server_controller_channel_orchestrator.go
Other components
- SQL client
- Cloud providers
Connections 13
- SQL client → SQL execution: submits SQL
- Built-in SQL client → SQL execution: sends SQL
- SQL execution → Transaction pipelining: coordinates transactions
- Transaction pipelining → KV replicas: sends KV batches
- KV replicas → Raft consensus: uses consensus storage
- KV replicas → MVCC engine: reads and writes
- Backup and restore → External storage API: stores backup data
- Changefeeds → Cloud sink: dispatches events
- Cloud sink → External storage API: writes files
- Stream ingestion → Job tracking: reads job state
- External storage API → Amazon S3: selects backend
- Cloud providers → Amazon S3: provides storage
- Tenant server lifecycle → SQL execution: starts tenant service