SQL Server Always On: Controlled Failover and a Real Drill

SQL Server Always On: Controlled Failover and a Real Drill

High availability means more than installing a second server. The real goals are the acceptable amount of data loss and the time allowed to restore service. Recovery Point Objective defines the data-loss boundary; Recovery Time Objective defines the restoration deadline. Technology cannot be judged successful until both are agreed with the business.

Synchronous and asynchronous replicas

With synchronous commit, the primary waits for the secondary to harden the log before completing the transaction. This reduces data-loss risk on low-latency links but adds network time to commits. Asynchronous commit suits a remote disaster-recovery location; the primary does not wait, so unsent log records may be lost during a failure.

Check health before failover

SELECT
    ar.replica_server_name,
    rs.role_desc,
    rs.connected_state_desc,
    drs.synchronization_state_desc,
    drs.synchronization_health_desc,
    drs.log_send_queue_size,
    drs.redo_queue_size
FROM sys.dm_hadr_database_replica_states AS drs
JOIN sys.availability_replicas AS ar ON ar.replica_id = drs.replica_id
JOIN sys.dm_hadr_availability_replica_states AS rs ON rs.replica_id = ar.replica_id;

Before a planned failover, confirm that the intended secondary is synchronized, queues are within limits, and recent backups are verified. Forced failover can lose data and belongs only in an explicitly accepted disaster scenario.

The application connection matters

Server=tcp:blog-ag-listener,1433;
Database=BlogDb;
Integrated Security=True;
MultiSubnetFailover=True;
Connect Timeout=15;
TrustServerCertificate=False;

Applications should use the Availability Group listener rather than a physical server name. Retry transient connection errors with a limited jittered policy, but remember that retrying a payment or another side effect requires an idempotency key.

Drill sequence

  1. Write the event that starts the RTO clock and the criteria that stop it.
  2. Capture replica health, log queues, backups, and application alarms.
  3. Perform a planned failover in a maintenance window.
  4. Verify reads, writes, jobs, and integrations on the new primary.
  5. Compare critical row counts and recent business identifiers.
  6. Fail back and compare measured RTO with the target.

Conclusion

An Availability Group is a tool, not a recovery guarantee. Listener behavior, application retries, dependent server objects, monitoring, and regular drills turn a diagram into real recovery capability.

//

0 Comments

Write Comment

E-Mail address will not be published