Clients don’t need a Witness with Database Mirroring

SQL Server 2005 introduced the much awaited Database Mirroring feature. OK, so we had to wait for SP1 for official support and for SQL Server 2008 for some enhancements like better performance and automatic repair. It’s still a great feature if you need failover of a database without the expense of a cluster. One surprising aspect of Database Mirroring is that the clients will transparently redirect themselves no matter what mode we are using.

The default mode of Database Mirroring is High Availability. This requires three SQL Server instances to play the roles of Principal, Mirror and Witness. The Principal hosts the updateable principal database, the Mirror hosts the synchronized mirror database and the Witness determines when an automatic failover is required. The Principal and the Mirror need to be Standard Edition or above. The Witness can be any edition including the Express edition. The updates on the principal are committed synchronously with the mirror so during a failover there is no loss of data – guaranteed.

If you do not require automatic failover, you can dispense with the Witness role and use High Protection mode. Manual failover is still available and again there is no loss of data during failover because of synchronous updates between principal and mirror.

If the synchronous updates are causing performance issues you can use High Performance mode which allows asynchronous updates between principal and mirror databases. This means that a commit on the principal does not have to wait for the two-phase commit from the mirror. The principal can continue undeterred while the mirror catches up; however in this mode there is no guarantee that some last minute transactions may not be lost during a failover. Because there is no Witness option in this mode, only manual failover is available.

But what about the client connections? They will actually redirect themselves using a process called Transparent Client Redirection assuming you are using the SQL Native Client or ADO.Net 2.0 or above. This is because the connection string now has two slots, one for the default Server Name and one for the “Failover Partner”. If one doesn’t work then it will try the second. This works independently of the Witness so is available for all three modes of Database Mirroring.

To me, this was a surprising bonus to the Database Mirroring feature. It just goes to show that if you don’t have a witness, you can simply look in the mirror.

Cheers,

Brian

Related Courses

SQL Server 2008 for Administration (M6231, M6232)

Developing and Implementing a SQL Server 2008 Database (M6232)

In this article

Join the Conversation

2 comments

  1. MataguaySky Reply

    Brian, What about those of us that want manual Failover?

    My Client sees an issue and tries to contact the mirror even if I do not want it to.

    I do not consider that a bonus. 🙁

    1. Brian Egler Reply

      If you omit the FAILOVER_PARTNER connection property it will not redirect the client automatically. Then you could redirect manually yourself. But why wouldn’t you want a connection? The client would be disconnected and the redirection would reconnect automatically.
      Hope this helps.
      Brian