This feature is in and subject to change. To share feedback and/or issues, contact Support.
ALTER VIRTUAL CLUSTER statement initiates a failover or failback in a and manages a virtual cluster.
PCR happens between an active primary cluster and a passive standby cluster that accepts updates from the primary cluster. The unit of replication is a virtual cluster, which is part of the underlying infrastructure in the primary and standby clusters. The CockroachDB cluster has:
- The system virtual cluster manages the cluster’s control plane and the replication of the cluster’s data. Admins connect to the system virtual cluster to configure and manage the underlying CockroachDB cluster, set up PCR, create and manage a virtual cluster, and observe metrics and logs for the CockroachDB cluster and each virtual cluster.
- The application virtual cluster manages the cluster’s data plane. Application virtual clusters contain user data and run application workloads.
Required privileges
ALTER VIRTUAL CLUSTER requires one of the following privileges:
- The
adminrole. - The
MANAGEVIRTUALCLUSTERallows the user to run all the relatedVIRTUAL CLUSTERSQL statements for PCR.
Synopsis
xml version=“1.0” encoding=“UTF-8”?Parameters
| Parameter | Description |
|---|---|
virtual\_cluster\_spec | The virtual cluster’s name. |
PAUSE REPLICATION | Pause the replication stream. |
RESUME REPLICATION | Resume the replication stream. |
COMPLETE REPLICATION TO | Set the time to complete the replication. Use:
|
START REPLICATION OF virtual\_cluster\_spec ON physical\_cluster | Reset a virtual cluster to the time when the virtual cluster on the promoted standby diverged from it. To reuse as much of the existing data on the original primary cluster as possible, you can run this statement as part of the process. This command fails if the virtual cluster was not originally replicated from the original primary cluster. |
START SERVICE SHARED | Start a virtual cluster so it is ready to accept SQL connections after failover. |
RENAME TO virtual\_cluster\_spec | Rename a virtual cluster. |
STOP SERVICE | Stop the shared service for a virtual cluster. The virtual cluster’s data\_state will still be ready so that the service can be restarted. |
GRANT ALL CAPABILITIES | Grant a virtual cluster all . |
REVOKE ALL CAPABILITIES | Revoke all from a virtual cluster. |
GRANT CAPABILITY virtual\_cluster\_capability\_list | Specify a to grant to a virtual cluster. |
REVOKE CAPABILITY virtual\_cluster\_capability\_list | Revoke a from a virtual cluster. |
Examples
Start the failover process
To start the process, useCOMPLETE REPLICATION and provide the timestamp to restore as of:
SYSTEM TIMEto specify a .LATESTto specify the most recent replicated timestamp.
shared service for a virtual cluster and prevent it from accepting SQL connections:
Start the failback process
To to a cluster that was previously the primary cluster, use theALTER VIRTUAL CLUSTER syntax:
If you started the original PCR stream on an existing cluster without virtualization enabled, refer to the section for instructions.

