Prerequisites
This page assumes you have read and understood the following:- Replication controls > Replication zone levels, which describes how the inheritance hierarchy of replication zones works. This is critical to understand for troubleshooting.
- Monitoring and alerting > Critical nodes endpoint, which is used to monitor if any of your cluster’s ranges are under-replicated, or if your data placement constraints are being violated.
SHOW ZONE CONFIGURATIONS, which is the SQL statement used to view details about the replication zone configuration of various schema objects.
Types of problems
The most common types of problems you may encounter when manually configuring replication zones are:- The replica location problem, a.k.a., “The replicas are not where they should be”. For replica location problems, the following zone config variables may be involved:
- The replica state problem, a.k.a., “The replicas are not how they should be”. For replica state problems, the following zone config variables may be involved:
If you just did a cluster restore and are seeing problems with your zone configs, it may be because zone configs are overwritten by a cluster restore.
Troubleshooting steps
Use the following steps to determine which schema objects (if any) have zone configurations that are misconfigured. The examples assume a local multi-regioncockroach demo cluster started using the following command:
movr database:
Step 1. Start with a target schema object
Look at the zone configuration for the schema object that you think may be misconfigured. Depending on the type of problem, you might have come to this conclusion by monitoring the critical nodes endpoint. Use theSHOW ZONE CONFIGURATION statement to inspect the target object’s zone configurations.
For example, to view the zone configuration for the movr.rides table:
movr.users is using the zone configuration from its parent movr database. For more information about how this works, see How zone config inheritance works.
However, if the zone configuration had been manually modified, there could be inconsistencies in the output that would show a misconfiguration.
For example:
- If the type of problem were a constraint violation, you’d want to check whether the values in
constraints,voter_constraints, andlease_preferencesare logically inconsistent, which would cause constraint violations. - If the type of problem were an under-replicated range, you’d want to check the values of
num_replicasandnum_voters. Modifying these values can cause under-replication. For example,num_replicascould be set too low. It’s also easy to make an arithmetic mistake when configuringnum_voters; ifnum_votersis less thannum_replicas, the difference dictates the number of non-voting replicas. This is why most users should control non-voting replica placement with the high-level multi-region SQL features instead. - If range splits are failing, the value of
gc.ttlsecondsmay be too high.
ALTER TABLE ... CONFIGURE ZONE. You can set the problem-causing field to another value, but often the best thing to do is to discard the changed settings using ALTER TABLE ... CONFIGURE ZONE DISCARD so that it returns to inheriting values from its parent object:
Step 2. Move upward in the inheritance hierarchy as needed
If the target schema object looked good in Step 1, look at its parent schema object at the next level up in the inheritance hierarchy. This is the new target schema object. Return to the previous step and follow the instructions there. Continue this process recursively until you either find the misconfigured zone configuration or make it all the way up to thedefault replication zone and confirm that all of your schema objects have the expected zone configurations.
Considerations
Monitor for ranges that are under-replicated or violating constraints
Monitor the output of the critical nodes endpoint to see if you have ranges that are under-replicated or violating constraints. Using the range IDs from that endpoint, you can map from range IDs to schema objects as described in the following example. This will give you a target schema object to start from.- To monitor for under-replicated range IDs, see Critical nodes endpoint > Replication status - under-replicated ranges.
- To monitor for range IDs that are violating constraints, see Critical nodes endpoint > Replication status - constraint violation.
SHOW ZONE CONFIGURATIONS.
The following example query uses the SHOW RANGES statement to show, for each range ID, which tables and indexes use that range for their underlying storage. The query assumes the movr schema that is loaded by cockroach demo, so you’ll need to modify it to work with your schema.
101, we would know to look at the zone configuration(s) for the users table and the users_pkey primary index.
Replication system priorities: data placement vs. data durability
As noted in Data Domiciling with CockroachDB:Performance
Changes you make to a schema object’s zone configuration may take some time to be reflected in the schema object’s actual state, and can result in an increase in CPU usage, IOPS, and network traffic while the cluster rebalances replicas to meet the provided constraints. This is especially true for larger clusters. For more information about how replica rebalancing works, see Load-based replica rebalancing.Zone configs are overwritten during cluster restore
During a cluster restore, any zone configurations present on the destination cluster are overwritten with the zone configurations from the backed-up cluster. If no customized zone configurations were on the cluster when the backup was taken, then after the restore the destination cluster will use the zone configuration from theRANGE DEFAULT configuration.
For more information, see RESTORE considerations.
See also
- Troubleshooting overview
- Troubleshoot Self-Hosted Setup > Replication issues
- Replication Controls
- Critical nodes status endpoint: check the status of your cluster’s data replication, data placement, and zone constraint conformance.

