Execute the database script using tctl command


I would like to clean up the cluster_metadata table using the tctl command on every startup of the server, how to do it?
I don’t want to do it manually by running the delete from cluster_metadata

@jaffarsadik can you explain why you need to clear cluster metadata? There might be additional cluster level configs added to cluster_metadata in future server releases and they should probably not be deleted /cleared on every startup.

I will be using single cockroach database.

Temporal app I would like to go for active and passive clusters.

during the DR activity i would like to turn off active cluster and turn on passive cluster.
cluster-metadata table is immutable it looks for cluster name during the startup. when i turn on passive cluster table contains the info of active cluster.

Basically the same data should be display on both cluster during the switch of the clusters.

Are you using one db instance (same data copy) for both active and passive cluster? You should not do that, the behavior is undefined and you likely will have data corruption issue down the road.

Yes single database should appear in both clusters of the workflows.

With this configuration

enableGlobalNamespace: true
failoverVersionIncrement: 10
masterClusterName: “active”
currentClusterName: “active”
enabled: true
initialFailoverVersion: 1
rpcName: “frontend”
rpcAddress: “##TEMPORAL_POD_IP##:7233

@jaffarsadik could you clarify a bit more? Do you have 2 clusters both connecting to the same database instance, and both have the same config content? Are both of these 2 clusters think they are the active one?

Yes both clusters use the same database & configuration and in active-active mode.

That is not how temporal is designed to work. I suspect instances in your 2 clusters are able to talk to each other and they are using same membership port. If that is the case, then they in fact form ONE bigger cluster.
Temporal cluster cannot operate in active-active mode. If you do have 2 separate clusters (e.g. their history instances cannot talk directly to each other in different cluster), and they share same database, then both of them will steal shard from each other constantly, temporal won’t be able to operate in that mode.

Active - Passive cluster mode also doesn’t sync the data as per understanding.

2 clusters should not share database instance.
You can use tctl command to failover namespace from one cluster to the other cluster, you can do this in disaster recovery by hand or by code.

Can you please share how can do this by manual or code?

Sure. By TCTL command: