Sql-server – behavior of a Sql Server availability group listener and a jdbc client during a failover

availability-groupshigh-availabilitysql server

i have a question about the behavior of the AG listener during a failover… when the failover happens, I realize that all the connections on both primary and secondaries are closed.

if the client apps are using one of the blessed client libraries (such as microsoft jdbc > 6.0) they will then start immediately trying to reconnect to the ip addresses associated with the listener. But what happens during the 10 second period (or whatever it is) for the failover to complete? Might a client successfully get a connection, only to get a fatal error message when it tries to use it? Or is something done to ensure that no client will get a connection successfully during failover itself, so that that when a client does successfully get a connection, it is actually usable?

(FYI regarding the behavior of the microsoft jdbc driver, judging from the source code at:
https://github.com/microsoft/mssql-jdbc/blob/dev/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
It will divide the configured loginTimeout by 8 and so make 8 attempts before timing out.)

Best Answer

My understanding is that no client is going to be able to connect to the Listener and get a database connection until the failover completes. Look at the section "How Automatic Failover Works" in the following link. See here