Before you beginBuild and verify the secondary failover group
Prepare the drill, the roles and the stop conditions
Use two eligible Business Critical or higher test accounts and the verified failover group from the previous lesson. Agree who can start or abort the exercise: incident lead, Snowflake operator for the group, client operator, and data owner who signs off on counts and amounts. Record identities, approved recipients and test windows. Use fictional data and do not redirect real client traffic.
Before the drill, verify the secondary snapshot, role grants, warehouse, client credentials and remote dependencies. Find the last verified batch and known totals in both accounts. Confirm no unexpected external jobs are writing. Capture what you will compare after promotion. Ask integration owners to check supported pipe, task, alert and dynamic-table behavior and verify external credentials or queue paths separately.
| Check | Expected evidence | If it fails |
|---|---|---|
| Group membership | MAPLE_SALES_FG contains the scratch database | Stop and fix the test scope. |
| Recovery point | Completed refresh and B102 present | Fix or wait for refresh before promotion. |
| Client test | Target account login, role and warehouse usable | Prepare the identity and compute first. |
| Writer control | Sources, scheduler and application writers accounted for | Keep the drill paused until the switch is safe. |
Stop source writes and confirm the secondary is ready
For a planned drill, pause the lab scheduler and test application writers. The primary group owner or authorized failover role can use SET READ_ONLY to prevent new writes to group objects. The read-only flag does not cancel an already running query. Confirm in-flight writes have ended before taking the final snapshot. On an unplanned outage with no source access, record the last good replica and fence external writers where you still control them. Do not assume that you can do a final refresh.
The separate secondary operator uses the owner or REPLICATE role to take a final refresh in the planned drill. Check the job history and wait for a completed refresh. Review the snapshot timestamp, count and amount. If a refresh is running, normal SQL promotion fails; wait in a planned drill. An emergency cancellation has consistency implications and needs an explicit decision.
- MAPLE_EASTFinal copy to MAPLE_WEST secondary
- MAPLE_WEST secondaryApprove to MAPLE_WEST primary
- MAPLE_WEST primaryVerify to Application check
- MAPLE_EAST
- Pause writers and put the lab group into read-only mode.
- MAPLE_WEST secondary
- Refresh, inspect the final job and verify data.
- MAPLE_WEST primary
- Promote the group and redirect or reconfigure clients.
- Application check
- Confirm reads and one controlled write before resuming.
-- Original primary, approved drill window:
ALTER FAILOVER GROUP MAPLE_SALES_FG SET READ_ONLY = TRUE;
SHOW FAILOVER GROUPS;
SHOW TRANSACTIONS;
-- Secondary, only after confirming lab writers drained:
ALTER FAILOVER GROUP MAPLE_SALES_FG REFRESH;
SELECT job_uuid, phase_name, primary_snapshot_timestamp, end_time, error
FROM TABLE(INFORMATION_SCHEMA.REPLICATION_GROUP_REFRESH_HISTORY('MAPLE_SALES_FG'))
ORDER BY start_time DESC, end_time DESC NULLS FIRST;Prepare Client Redirect or a manual connection switch
A failover group controls the objects and their write location. A connection object controls where a client connects. Client Redirect requires Business Critical or higher, replication-enabled accounts in the same organization and different regions. With approved administrators, create a connection on the source, allow the target, then create a link with the same name in the target. Copy the approved connection URL into your test client before the drill and plan for new sessions after promotion. Follow the DNS procedure separately for private connectivity.
If the client uses direct account names, pre-test a separate target profile and switch configuration during the drill. Reconnect the client using its real recovery role and warehouse. Switching a hostname does not move data, roles or an existing session.
-- Original primary, as account administrator:
CREATE CONNECTION MAPLE_SALES_APP;
ALTER CONNECTION MAPLE_SALES_APP ENABLE FAILOVER TO ACCOUNTS MAPLEORG.MAPLE_WEST;
SHOW CONNECTIONS;
-- Secondary, as account administrator:
CREATE CONNECTION MAPLE_SALES_APP AS REPLICA OF MAPLEORG.MAPLE_EAST.MAPLE_SALES_APP;
SHOW CONNECTIONS;Promote, reconnect and validate the recovered service
After the incident lead approves promotion, run the group command from the secondary as its owner or an authorized FAILOVER role. If you configured Client Redirect, use the delegated connection FAILOVER role or account admin to promote the corresponding connection. With a direct profile, switch the approved client settings instead. Keep normal jobs paused until the checks below pass.
Run the read from the application’s new session. Confirm the account and region as well as the four orders and total 250. Confirm the B102 publication marker in BATCH_AUDIT. For the write test, use the application or approved test-writer role with INSERT and SELECT on DR_MARKERS. Use a unique marker value for this exercise. Successful authentication and a readable table alone do not prove writing works.
| Check | Expected result |
|---|---|
| Client identity | MAPLE_WEST and the approved role |
| Sales read | 4 orders and 250.00; B102 has a PUBLISHED attempt |
| Write | DR-WEST-001 present once |
-- Secondary account, after approval and a completed refresh:
ALTER FAILOVER GROUP MAPLE_SALES_FG PRIMARY;
-- If using Client Redirect, as the authorized connection operator:
ALTER CONNECTION MAPLE_SALES_APP PRIMARY;
-- New application session using the approved recovery profile:
SELECT CURRENT_ACCOUNT_NAME(), CURRENT_REGION(), CURRENT_ROLE();
SELECT COUNT(*) AS orders, SUM(amount) AS sales FROM LS_M20_OPS_LAB.OPS.SALES_TARGET;
SELECT batch_id, attempt_no, status FROM LS_M20_OPS_LAB.OPS.BATCH_AUDIT
WHERE batch_id = 'B102' ORDER BY attempt_no;
INSERT INTO LS_M20_OPS_LAB.OPS.DR_MARKERS (marker_id, written_at)
VALUES ('DR-WEST-001', CURRENT_TIMESTAMP());
SELECT marker_id FROM LS_M20_OPS_LAB.OPS.DR_MARKERS WHERE marker_id = 'DR-WEST-001';Fail back only after verifying new writes on the original account
When the original region is ready, it is a secondary. Schedule a new switch, pause external writers and set the current MAPLE_WEST primary group read-only. Refresh MAPLE_EAST from MAPLE_WEST and wait for a successful job. From MAPLE_EAST, verify that DR-WEST-001 and any other writes accepted in the drill are present. Then promote MAPLE_EAST, move connections, and run the application checks again.
If an approved planned drill stops before promotion, the source group owner or FAILOVER role can restore the still-primary group with UNSET READ_ONLY, if that is the authorized rollback. If you already promoted, coordinate a failback instead. Check dynamic tables and integrations explicitly after either action. For example, an automatically suspended dynamic table may need to be resumed manually.
Save the old and new snapshot times, queries, client checks, observed data gap and service interruption. Stop the test scheduler, suspend test refreshes if no longer needed and have account administrators clean up the approved connections, secondary group then primary group, and any standalone replica database they no longer need. Cleanup is separate from proving failback.
-- MAPLE_WEST, now primary: first pause external lab writers.
ALTER FAILOVER GROUP MAPLE_SALES_FG SET READ_ONLY = TRUE;
-- MAPLE_EAST, now secondary: confirm latest job completed after this refresh.
ALTER FAILOVER GROUP MAPLE_SALES_FG REFRESH;
SELECT marker_id FROM LS_M20_OPS_LAB.OPS.DR_MARKERS WHERE marker_id = 'DR-WEST-001';
-- MAPLE_EAST after validation and change approval:
ALTER FAILOVER GROUP MAPLE_SALES_FG PRIMARY;
-- When used, promote the Client Redirect connection here too:
ALTER CONNECTION MAPLE_SALES_APP PRIMARY;Interview practice
Explain the decision and the evidence you would use to test it.
Beginner · Why test connections separately from data?
A copy can be valid while a client still signs in to the wrong account or cannot get the right role. I confirm the account, role, read and write paths before resuming.
SQL · Which queries show readiness?
I combine SHOW FAILOVER GROUPS and recent refresh history with a select of the last batch marker and reconciled totals. After promotion I verify a single controlled write from the client session.
Production · How do you handle failback after a regional outage?
I keep one active write destination, refresh the original region from the current primary, compare fresh markers and reconcile the data. Then I switch clients and verify the application there before reopening writes.
Words used in this lesson
- Quiesce
- Pause or block new writes and let controlled work settle before a switch.
- Write fence
- A control that keeps old jobs or clients from writing after the service moves.
- Client Redirect
- A Snowflake connection object that can direct new connections to another eligible account.
- Failback
- A planned move of the service back to the original account after it catches up.
Try the SQL or command
Read → predict → run in your learning environment → compare. You can also learn by reading without an account.
Use the SQL and expected outputs in the sections above.
New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
Before running this lesson
Maple Market is fictional. Output tables are representative. Live commands require an authorized test account and the roles, compute and edition listed in each lesson.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
After promotion, the service test can read the new account but the application role cannot write its marker. Do you end the RTO clock?
Compare your reasoning
No. Keep normal writers paused. Check client account identity, write mode, role grants and network/auth settings. End the clock after the defined application checks pass.
Connect this lesson to the learning path
Official sources and curriculum
Module 20 · See module scope
By Rohit Ray · Independent educational lesson · Explore this visual lab