Just retrying the connection should be enough. When an instance is in the middle of a failover and our application has a connection open, here's what happens:
- The connection is working
- SQLException: "A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)"
- SQLException: "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)"
- The message in step 3 will be repeated until the failover is complete.
- Reconnect successfully.
In this case, you'd only need to attempt to retry the connection. If your SQL server is generally pretty responsive, you can try wrapping your connection code in a class where a database call times out after 30 seconds, but inside the class, use a shorter timeout and retry a few times. That will give your application at large only one call to make, and allow the internal connections time to fail over if need be.
The transition of the network name and IP address are seamless though, so there's nothing special you'll need to do to recover if a failover occurs - just reconnect and keep chugging. Keep in mind, though, that any in-process transactions will be rolled back, so if you had anything that was running when the disconnect occurred, you'll need to resubmit it on the new node.