Role Switching

Role switching in database mirroring is a process to change the principal and mirror roles. Three types of role switching exist based on the database mirroring operating mode: automatic failover, manual failover, and forced failover.

Automatic failover is available only in synchronous mode with failover. In this mode, if the principal database becomes unavailable due to any failure and the mirror and witness servers are still connected and the mirroring state is SYNCHRONIZED, automatic failover occurs. Here is a high-level sequence of events that occur in an automatic failover scenario:

1. The principal database becomes unavailable due to some failure.
2. If the principal server is still available, the state of the principal database is changed to DISCONNECTED and all the clients are disconnected from the principal database.
3. The mirror and the witness server detect the failure.
Note
The default timeout for communication between the principal, mirror, and witness servers is 10 seconds. If the principal does not respond within the timeout period, it is considered to be down. If you use high-safety mode, you can change the timeout period using the ALTER DATABASE SET PARTNER TIMEOUT command. The default timeout of 10 seconds works well for most environments. If you do want to change the timeout period, do not set it below 10 seconds because this may cause false failures.
4. The mirror server recovers the mirror database.
5. The mirror server forms a quorum ...

Get Microsoft SQL Server 2012 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.