Terminology
Before upgrading, review the CockroachDB path=“index” terminology:- A new major release is performed multiple times per year. The major version number indicates the year of release followed by the release number, starting with 1. For example, the latest major release is v26.1.
- Each major release is maintained across patch releases that contain improvements including performance or security enhancements and bug fixes. Each patch release increments the major version number with its corresponding patch number. For example, patch releases of v26.1 use the format v26.1.x.
- All major and patch releases are suitable for production environments, and are therefore considered “production releases”. For example, the latest production release is v26.1.1.
- Prior to an upcoming major release, alpha, beta, and release candidate (RC) binaries are made available for users who need early access to a feature before it is available in a production release. These releases append the terms
alpha,beta, orrcto the version number. These “testing releases” are not suitable for production environments and are not eligible for support or uptime SLA commitments. For more information, refer to the .
There are no “minor releases” of CockroachDB.
Step 1. Verify that you can upgrade
In CockroachDB v22.2.x and above, a cluster that is upgraded to an alpha binary of CockroachDB or a binary that was manually built from the
master branch cannot subsequently be upgraded to a production release.- Any earlier v23.2 release: v23.2.0-alpha.1 to v23.2.28.
- A v23.1 production release: v23.1.0 to v23.1.30.
| Version | Action(s) before upgrading to any v23.2 release |
|---|---|
| Pre-v23.2 testing release | Upgrade to a corresponding production release; then upgrade through each subsequent major release, ending with a v23.1 production release. |
| Pre-v23.1 production release | Upgrade through each subsequent major release, ending with a v23.1 production release. |
| v23.1 testing release | Upgrade to a v23.1 production release. |
Step 2. Prepare to upgrade
Before starting the upgrade, complete the following steps.Ensure you have a valid license key
To perform major version upgrades, you must have . Patch version upgrades can be performed without a valid license key, with the following limitations:- The cluster will run without limitations for a specified grace period. During that time, alerts are displayed that the cluster needs a valid license key. For more information, refer to the .
- The cluster is at the end of the grace period if no before then.
- The cluster will run without limitations for a 7-day grace period. During that time, alerts are displayed that the cluster needs to send telemetry.
- The cluster is if telemetry is not received before the end of the grace period.
Review breaking changes
Review the , , and in v23.2. If any affect your deployment, make the necessary changes before starting the rolling upgrade to v23.2.Check load balancing
Make sure your cluster is behind a , or your clients are configured to talk to multiple nodes. If your application communicates with a single node, stopping that node to upgrade its CockroachDB binary will cause your application to fail.Check cluster health
Verify the overall health of your cluster using the :- Under Node Status, make sure all nodes that should be live are listed as such. If any nodes are unexpectedly listed as
SUSPECTorDEAD, identify why the nodes are offline and either restart them or them before beginning your upgrade. If there areDEADand non-decommissioned nodes in your cluster, it will not be possible to finalize the upgrade (either automatically or manually). - Under Replication Status, make sure there are
0under-replicated and unavailable ranges. Otherwise, performing a rolling upgrade increases the risk that ranges will lose a majority of their replicas and cause cluster unavailability. Therefore, it’s important to identify and resolve the cause of range under-replication and/or unavailability before beginning your upgrade. - In the Node List:
- Make sure all nodes are on the same version. If any nodes are behind, upgrade them to the cluster’s current version first, and then start this process over.
- In the Metrics dashboards:
- Make sure , , and capacity are within acceptable values for each node. Nodes must be able to tolerate some increase in case the new version uses more resources for your workload. If any of these metrics is above healthy limits, consider to your cluster before beginning your upgrade.
Check decommissioned nodes
If your cluster contains partially-decommissioned nodes, they will block an upgrade attempt.-
To check the status of decommissioned nodes, run the command:
In the output, verify that the value of the
membershipfield of each node isdecommissioned. If any node’smembershipvalue isdecommissioning, that node is not fully decommissioned. -
If any node is not fully decommissioned, try the following:
- First, reissue the . The second command typically succeeds within a few minutes.
- If the second decommission command does not succeed, and then decommission it again. Before continuing the upgrade, the node must be marked as
decommissioned.
Back up cluster
Because CockroachDB is designed with high fault tolerance, backups are primarily needed for . However, taking regular backups of your data is an operational best practice. When upgrading to a major release, we recommend of your cluster. See our .Step 3. Decide how the upgrade will be finalized
This step is relevant only when upgrading from v23.1.x to v23.2. For upgrades within the v23.2.x series, skip this step. By default, after all nodes are running the new version, the upgrade process will be auto-finalized. This will enable certain features and performance improvements introduced in v23.2. However, it will no longer be possible to roll back to v23.1 if auto-finalization is enabled. In the event of a catastrophic failure or corruption, the only option will be to start a new cluster using the previous binary and then restore from one of the backups created prior to performing the upgrade. For this reason, we recommend disabling auto-finalization so you can monitor the stability and performance of the upgraded cluster before finalizing the upgrade, but note that you will need to follow all of the subsequent directions, including the manual finalization in step 6:- Upgrade to v23.1, if you haven’t already.
- Start the shell against any node in the cluster.
-
Set the
cluster.preserve_downgrade_option:It is only possible to set this setting to the current cluster version.
Features that require upgrade finalization
When upgrading from v23.1 to v23.2, certain features and performance improvements will be enabled only after finalizing the upgrade, including but not limited to:- The coalescing of storage ranges for each table, index, or partition (collectively referred to as “schema objects”) into a single range when individual schema objects are smaller than the default configured maximum range size (controlled using zone configs, specifically the
range_max_bytes parameter). This change improves scalability with respect to the number of schema objects, since the underlying range count is no longer a potential performance bottleneck. After finalizing the upgrade to v23.2, you may observe a round of range merges and snapshot transfers. To disable this optimization, before finalizing the upgrade, set thespanconfig.storage_coalesce_adjacent.enabledtofalse. See the forSHOW RANGESfor more details. - The new output log format, which allows configuration of a time zone in log output. Before configuring a time zone, the cluster must be finalized on v23.2.
- Performance improvements when a node reclaims disk space.
- The following mechanisms, which help to maintain cluster performance and availability when some nodes experience high load:
- Delete operations
- Replication
- Collecting a statement diagnostic bundle for a particular plan. The existing fingerprint-based matching has been extended to also include plan-gist-based matching and “anti-matching” (collecting a bundle for any plan other than the provided plan gist).
- A new system table,
system.region_liveness, that tracks the availability and the timestamp of the latest unavailability for each cluster region. - The ability of a
WaitPolicy_Errorrequest to push the timestamp of a transaction with a lower priority. - Configuring a changefeed with the
lagging_ranges_thresholdorlagging_ranges_polling_interval. - Removal of the upgrade step
grantExecuteToPublicOnAllFunctions, which is no longer required because post-serialization changes now grantEXECUTEon functions to the public role. - A fix to a bug that could allow a user to execute a user-defined function without the
EXECUTEprivilege on the function. If a user does not have the privilege, the user-defined function does not run and an error is logged.
Step 4. Perform the rolling upgrade
Follow these steps to perform the rolling upgrade. To upgrade CockroachDB on Kubernetes, refer to or instead. For each node in your cluster, complete the following steps. Be sure to upgrade only one node at a time, and wait at least one minute after a node rejoins the cluster to upgrade the next node. Simultaneously upgrading more than one node increases the risk that ranges will lose a majority of their replicas and cause cluster unavailability.After beginning a major-version upgrade, Cockroach Labs recommends upgrading all nodes as quickly as possible. In a cluster with nodes running different major versions of CockroachDB, a query that is sent to an upgraded node can be distributed only among other upgraded nodes. Data accesses that would otherwise be local may become remote, and the performance of these queries can suffer.
- .
- Visit and download the CockroachDB v23.2.29 full binary for your architecture.
- Extract the archive. In the following instructions, replace with the path to the extracted archive directory.
-
If you have a previous version of the
cockroachbinary in your$PATH, rename the outdatedcockroachbinary, and then move the new one into its place. If you get a permission error because thecockroachbinary is located in a system directory, addsudobefore each command. The binary will be owned by the effective user, which isrootif you usesudo. -
If a cluster has corrupt descriptors, a major-version upgrade cannot be finalized. In CockroachDB v23.2 and above, automatic descriptor repair is enabled by default. After restarting each cluster node on v23.2, monitor the for errors. If a descriptor cannot be repaired automatically, contact support for assistance completing the upgrade. To disable automatic descriptor repair (not generally recommended), set the environment variable
COCKROACH_RUN_FIRST_UPGRADE_PRECONDITIONtofalse. -
Start the node so that it can rejoin the cluster.
Re-run the command that you used to start the node initially, for example:
- Verify the node has rejoined the cluster through its output to or through the .
-
If you use
cockroachin your$PATH, you can remove the previous binary: -
After the node has rejoined the cluster, ensure that the node is ready to accept a SQL connection.
Unless there are tens of thousands of ranges on the node, it’s usually sufficient to wait one minute. To be certain that the node is ready, run the following command:
The command will automatically wait to complete until the node is ready.
- Repeat these steps for the next node.
- .
- Visit and download the CockroachDB v23.2.29 full binary for your architecture.
- Extract the archive. In the following instructions, replace with the path to the extracted archive directory.
-
If you have a previous version of the
cockroachbinary in your$PATH, rename the outdatedcockroachbinary, and then move the new one into its place. If you get a permission error because thecockroachbinary is located in a system directory, addsudobefore each command. The binary will be owned by the effective user, which isrootif you usesudo. -
If a cluster has corrupt descriptors, a major-version upgrade cannot be finalized. In CockroachDB v23.2 and above, automatic descriptor repair is enabled by default. After restarting each cluster node on v23.2, monitor the for errors. If a descriptor cannot be repaired automatically, contact support for assistance completing the upgrade. To disable automatic descriptor repair (not generally recommended), set the environment variable
COCKROACH_RUN_FIRST_UPGRADE_PRECONDITIONtofalse. -
Start the node so that it can rejoin the cluster.
Without a process manager like
systemd, re-run the command that you used to start the node initially, for example:If you are usingsystemdas the process manager, run this command to start the node: - Verify the node has rejoined the cluster through its output to or through the .
-
If you use
cockroachin your$PATH, you can remove the previous binary:If you leave versioned binaries on your servers, you do not need to do anything. -
After the node has rejoined the cluster, ensure that the node is ready to accept a SQL connection.
Unless there are tens of thousands of ranges on the node, it’s usually sufficient to wait one minute. To be certain that the node is ready, run the following command:
The command will automatically wait to complete until the node is ready.
- Repeat these steps for the next node.
Step 5. Roll back the upgrade (optional)
If you decide to roll back to v23.1, you must do so before the upgrade has been finalized, as described in the next section. It is always possible to roll back to a previous v23.2 version. To roll back an upgrade, do the following on each cluster node:- Perform a rolling upgrade, as described in the previous section, but replace the upgraded
cockroachbinary on each node with the binary for the previous version. - Restart the
cockroachprocess on the node and verify that it has rejoined the cluster before rolling back the upgrade on the next node. - After all nodes have been rolled back and rejoined the cluster, finalize the rollback in the same way as you would finalize an upgrade, as described in the next section.
Step 6. Finish the upgrade
Because a finalized major-version upgrade cannot be rolled back, Cockroach Labs recommends that you monitor the stability and performance of your cluster with the upgraded binary for at least a day before deciding to finalize the upgrade. Finalization is required only when upgrading from v23.1.x to v23.2. For upgrades within the v23.2.x series, skip this step.- If you disabled auto-finalization in step 3, monitor the stability and performance of your cluster for at least a day. If you decide to roll back the upgrade, repeat the rolling restart procedure with the previous binary. Otherwise, perform the following steps to re-enable upgrade finalization to complete the upgrade to v23.2. Cockroach Labs recommends that you either finalize or roll back a major-version upgrade within a relative short period of time; running in a partially-upgraded state is not recommended. A cluster that is not finalized on v23.1 cannot be upgraded to v23.2 until the v23.1 upgrade is finalized.
- Once you are satisfied with the new version, run against any node in the cluster to open the SQL shell.
-
Re-enable auto-finalization:
A series of migration jobs runs to enable certain types of features and changes in the new major version that cannot be rolled back. These include changes to system schemas, indexes, and descriptors, and enabling certain types of improvements and new features. Until the upgrade is finalized, these features and functions will not be available and the command
SHOW CLUSTER SETTING versionwill return23.1. You can monitor the process of the migration in the DB Console . Migration jobs have names in the format23.2-{migration-id}. If a migration job fails or stalls, Cockroach Labs can use the migration ID to help diagnose and troubleshoot the problem. Each major version has different migration jobs with different IDs.
All jobs must reach a terminal state before finalization can complete. Finalization can therefore take as long as the longest-running schema change. Otherwise, the amount of time required for finalization depends on the amount of data in the cluster, as the process runs various internal maintenance and migration tasks. During this time, the cluster will experience a small amount of additional load.
-
To confirm that finalization has completed, check the cluster version:
If the cluster continues to report that it is on the previous version, finalization has not completed. If auto-finalization is enabled but finalization has not completed, check for the existence of where decommission has stalled. In most cases, issuing the
decommissioncommand again resolves the issue. If you have trouble upgrading, contact Support.
storage.marked-for-compaction-files . When the metric’s value nears or reaches 0, the migration is complete and compaction activity will return to normal levels.
By default, the uses a compaction concurrency of 3. If you have sufficient IOPS and CPU headroom, you can consider increasing this setting via the COCKROACH_COMPACTION_CONCURRENCY environment variable. This may help to reshape the LSM more quickly in scenarios; and it can lead to increased overall performance for some workloads. Cockroach Labs strongly recommends testing your workload against non-default values of this setting.
Troubleshooting
After the upgrade has finalized (whether manually or automatically), it is no longer possible to downgrade to the previous release. If you are experiencing problems, we therefore recommend that you:- Run the command against any node in the cluster to capture your cluster’s state.
- from Cockroach Labs, sharing your debug zip.

