cockroach debug command provides advanced tools for debugging and troubleshooting CockroachDB clusters.
Synopsis
Description
Debug commands help diagnose issues with CockroachDB clusters, inspect internal state, and extract data from failed nodes. These commands are particularly useful when:- A node has failed and cannot restart
- Investigating data corruption or consistency issues
- Troubleshooting performance problems
- Extracting data from offline stores
- Analyzing cluster internals
Key Subcommands
debug zip
Collect diagnostic information from all nodes in a cluster.- Cluster status and configuration
- Node logs and stack traces
- Range distribution and replica status
- Schema and table statistics
- Recent query activity
- System metrics and events
debug zip is the primary tool for gathering information when reporting bugs or troubleshooting issues.Flags
Include detailed range replica information (can be large).
Comma-separated list of node IDs to exclude from collection.
Maximum time to wait for data collection per node.
Examples
debug keys
Dump all keys in a store’s storage engine.Flags
Print key values in addition to keys.
Print key and value sizes.
Base64-encoded table descriptor for decoding row data.
Examples
debug range-data
Dump all data for a specific range.Use
debug range-descriptors first to find range IDs.Flags
Show only replicated data (excludes local Raft state).
Examples
debug range-descriptors
Print all range descriptors in a store.debug raft-log
Print the Raft log for a specific range.debug estimate-gc
Estimate garbage collection impact without performing it.Helps predict GC impact before running actual garbage collection.
Arguments
store-directory- Path to node’s data directory (required)range-id- Specific range ID to analyze (optional, defaults to all)ttl-seconds- GC TTL in seconds (optional, defaults to 86400 = 24 hours)intent-age- Intent age threshold as duration (optional, defaults to 2h)
Examples
debug compact
Manually compact storage engine SSTables.Flags
Maximum concurrent compaction operations.
Example
debug check-store
Run consistency checks on store data files.- SSTable integrity
- Manifest consistency
- Key ordering
- File checksums
debug ballast
Create a ballast file to reserve disk space.Ballast files can be deleted in emergencies to free disk space, allowing the node to continue operating.
Flags
Size of ballast file. Accepts bytes, size suffixes (e.g.,
1GB), or percentage of disk.Examples
debug decode-key
Decode hex or base64-encoded keys.Flags
Key encoding format:
hex or base64.Decode as user key (without MVCC timestamp).
Examples
debug decode-value
Decode hex-encoded key-value pairs.debug merge-logs
Merge log files from multiple nodes into a single stream.Extremely useful for analyzing distributed behavior across nodes.
Flags
Filter messages before this time.
Filter messages after this time.
Regular expression to filter log messages.
Filter by program name (cockroach, cockroach-sql, etc.).
Examples
debug gossip-values
Dump gossip network values from a running node.- Node descriptors
- Store descriptors
- Liveness records
- Cluster ID
debug list-files
List files managed by the storage engine.Pebble Tool Integration
CockroachDB includes the Pebble storage engine debugging tool:db- Database introspectionmanifest- Manifest file inspectionsstable- SSTable analysiswal- Write-ahead log inspection
Connection Flags
Commands that connect to running clusters support:Node to connect to.
Certificate directory for secure connections.
Connect without encryption.
Common Use Cases
Investigating Failed Node
Troubleshooting Performance
Analyzing Distributed Issues
Best Practices
When to Use Debug Commands:
- Node won’t start and logs don’t provide sufficient information
- Investigating suspected data corruption
- Analyzing performance issues with storage layer
- Extracting data from failed clusters
- Working with Cockroach Labs support on complex issues
Troubleshooting
Cannot Open Store
- Ensure node is stopped
- Verify you have read permissions on data directory
- Check that encryption keys are available (if using encryption)
- Ensure sufficient disk space