ALTER VIRTUAL CLUSTER statement initiates a failover or failback in a physical cluster replication (PCR) job 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
MANAGEVIRTUALCLUSTERsystem privilege allows the user to run all the relatedVIRTUAL CLUSTERSQL statements for PCR.
GRANT SYSTEM statement:
Synopsis
Parameters
Examples
Start the failover process
To start the failover process, useCOMPLETE REPLICATION and provide the timestamp to restore as of:
SYSTEM TIMEto specify a timestamp.LATESTto specify the most recent replicated timestamp.
ready after initiating the failover process, you must start the service so that the virtual cluster is ready to accept SQL connections:
shared service for a virtual cluster and prevent it from accepting SQL connections:
Start the failback process
To fail back 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 Fail back after PCR from an existing cluster section for instructions.

