ALTER VIRTUAL CLUSTER

On this page Carat arrow pointing down
Note:

This feature is in preview and subject to change. To share feedback and/or issues, contact Support.

New in v23.2: The ALTER VIRTUAL CLUSTER statement initiates a cutover 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.
  • Each other virtual cluster manages its own data plane. Users connect to a virtual cluster by default, rather than the system virtual cluster. To connect to the system virtual cluster, the connection string must be modified. Virtual clusters contain user data and run application workloads. When PCR is enabled, the non-system virtual cluster on both primary and secondary clusters is named application.

For more detail, refer to the Physical Cluster Replication Overview.

Required privileges

ALTER VIRTUAL CLUSTER requires one of the following privileges:

  • The admin role.
  • The MANAGEVIRTUALCLUSTER system privilege allows the user to run all the related VIRTUAL CLUSTER SQL statements for PCR.

Use the GRANT SYSTEM statement:

icon/buttons/copy
GRANT SYSTEM MANAGEVIRTUALCLUSTER TO user;

Synopsis

ALTER VIRTUAL CLUSTER virtual_cluster_spec PAUSE RESUME REPLICATION COMPLETE REPLICATION TO SYSTEM TIME timestamp LATEST SET REPLICATION replication_options , START REPLICATION OF virtual_cluster_spec ON physical_cluster opt_with_replication_options SERVICE SHARED GRANT REVOKE ALL CAPABILITIES RENAME TO virtual_cluster_spec STOP SERVICE

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:
GRANT ALL CAPABILITIES Grant a virtual cluster all capabilities.
REVOKE ALL CAPABILITIES Revoke all capabilities from a virtual cluster.
GRANT CAPABILITY virtual_cluster_capability_list Specify a capability to grant to a virtual cluster.
REVOKE CAPABILITY virtual_cluster_capability_list Revoke a capability from a virtual cluster.
RENAME TO virtual_cluster_spec Rename a virtual cluster.
START SERVICE SHARED Start a virtual cluster. That is, start the standby's virtual cluster so it is ready to accept SQL connections after cutover.
STOP SERVICE Stop the shared service for a virtual cluster. Note that the virtual cluster's data_state will remain as ready for the service to be started once again.

Examples

Start the cutover process

To start the cutover process, use COMPLETE REPLICATION and provide the timestamp to restore as of:

icon/buttons/copy
ALTER VIRTUAL CLUSTER application COMPLETE REPLICATION TO {cutover time specification};

You can use either:

  • SYSTEM TIME to specify a timestamp.
  • LATEST to specify the most recent replicated timestamp.

When a virtual cluster is ready after initiating the cutover process, you must start the service so that the virtual cluster is ready to accept SQL connections:

icon/buttons/copy
ALTER VIRTUAL CLUSTER application START SERVICE SHARED;

To stop the shared service for a virtual cluster and prevent it from accepting SQL connections:

icon/buttons/copy
ALTER VIRTUAL CLUSTER application STOP SERVICE;

See also


Yes No
On this page

Yes No