I want to measure the time needed for SQL Server to switch server roles. Is there a way to know how long does it take the mirror to become the principal and ready for new updates?
Thank you very much!
I want to measure the time needed for SQL Server to switch server roles. Is there a way to know how long does it take the mirror to become the principal and ready for new updates?
Thank you very much!
Monitor using the profiler infrastructure for the Database Mirroring State Change Event Class. StartTime will contain the time of the event, State will contain the new state after the change. I'm not sure I remember if the state change occurs before the new principal runs the recovery or after though, you'll have to test and see. Judging from Nick's post I'd say is after, so the event is perfect for you.
have you tried looking in the errorlog on the server you've failed over to? should see something like this:
A really ugly brute-force method could be to have a little app that connetcs to the principal once per second. If you configure it with explicit client redirection, you'll be able to tell at what point it fails over and you can successfully connect to the new principal.
Look up the SqlConnection .Net class - the DataSource member on a successful connection gives you the server name you're connected to.
Keeping track of the times involved is a SMOC.
Hope this helps.