Replication failover example
This page shows an example of how a Sync Engine instance in one Snowflake account might transfer responsibilities to a Sync Engine instance in another account, for example in the case of a whole region outage.
In the example we set up a failover for continuous replication, but you can also get the same result with just a replication group.
Diagram
Setup process
Source side
In this scenario, we have created a sync with slug my-sync-slug, and the storage location has been set to store both the raw tables and the normalized views in PROD.RAW.

We use a database role named PROD.OMNATA_ROLE to simplify ownership.
This database will contain the sync'd data, but we also want to keep track of the configuration of the sync, as well as the state of all the streams. The stream state is what allows incremental syncs to continue from where they finished in the previous run.
We cannot just replicate the sync engine metadata directly; Snowflake does not support replication of native applications, plus it's stored in a hybrid table which also cannot be replicated.
So instead, we create a separate database:
Then we create a post run hook which takes a configuration snapshot from the sync engine:
Finally, we create a failover group to sync these two databases to the other account:
Target side
First, the sync engine must have been installed, along with the plugin application. There will also need to be a connection created to the same environment as the primary - it is not practical to replicate secrets.
Assuming a sync run and replication has occurred since you configured the source side, the latest configuration and state should be visible:

You can use this data to create a sync on the target side:
This query picks out the sync configuration metadata from the source sync engine and applies it to the local one. This query can be ran on a schedule to ensure that the sync configuration is kept up to date.
We also want to keep the sync state up to date:
After this point, you should be able to see the sync in the UI, and it should be configured the same as on the source account, with the stream state applied (visible on the Status tab).
Failing over
If you try to run a sync on the secondary, you will get this error:

By marking the failover group as the primary:
You make the PROD database writable, and syncs will start to work.
Failing back
This example doesn't cover replicating the sync state back in the other direction, but assuming that ACCOUNT_B did not act as the primary for a significant amount of time, you can just make ACCOUNT_A the primary again and it will resume from where it left off before the outage:
Last updated