Availability Group Readable database disconnections
Wednesday, November 16, 2011 at 4:38PM I've set up a 3 server database Availabilty Group scenario using SQL Server 2012 CTP3 to allow me to prepare some implementation tests:
- L02-DB-01 (Primary)
- L02-DB-02 (Synchronous Secondary)
- L02-DB-03 (Asynchronous Readable Secondary)
One of the tests I prepared was a query to continously query the number of rows of data in a table on the L02-DB-03 and print the result with output that looks like this:
2011-11-16 15:34:36.353: Occurence 1 has count =6
2011-11-16 15:34:36.353: Occurence 2 has count =6
2011-11-16 15:34:36.353: Occurence 3 has count =6
If it gets disconnected it is scripted to automatically reconnect. I planned to use this to show how the read only connection for reporting stays up during the failover from the primary to the synchronous secondary node replica. And if it does get disconnected it then shows how long it takes before this can occur.
It turns out that connections to the asynch readable secondary get disconnected during a failover from one replica to another - at least in CTP3. The disconnection message is:
2011-11-16 15:34:47.877: Occurence 179344 has count =6
TCP Provider: An existing connection was forcibly closed by the remote host.
Communication link failure
If you try to reconnect, using sqlcmd, it generates an error message:
Msg 976, Level 14, State 1, Server L02-DB-03, Line 12
The target database, 'AvGroupDB1', is participating in an availability group and is currently not accessible for queries. To allow read-only access to this and other databases in the availability group, enable read access to one or more secondary availability replicas in the group. For more information, see the ALTER AVAILABILITY GROUP statement in SQL Server Books Online.
It's not what I was expecting but I guess it's reasonable given that the state of the database is a little vague during that time. If using this database to provide view access to the data it would be a good idea to check for disconnects and also for this error message when trying to connect / re-connect.
In my test it was not possible to re-connect to the database for approx. 16 secs although I guess this will depend on the servers and load on them.
The relevant section of the generated log is:
>sqlcmd -S l02-db-03 -E -i Read_Async.sql
Changed database context to 'tempdb'.
2011-11-16 17:00:55.307: Occurence 1 has count =6
2011-11-16 17:00:55.310: Occurence 2 has count =6
2011-11-16 17:00:55.310: Occurence 3 has count =6
2011-11-16 17:00:55.310: Occurence 4 has count =6
2011-11-16 17:00:55.310: Occurence 5 has count =6
2011-11-16 17:00:55.310: Occurence 6 has count =6
2011-11-16 17:01:04.273: Occurence 139693 has count =6
2011-11-16 17:01:04.273: Occurence 139694 has count =6
2011-11-16 17:01:04.273: Occurence 139695 has count =6
Msg 976, Level 14, State 1, Server L02-DB-03, Line 17
The target database, 'AvGroupDB1', is participating in an availability group and is currently not accessible for queries. To allow read-only access to this and other databases in the availability group, enable read access to one or more secondary availability replicas in the group. For more information, see the ALTER AVAILABILITY GROUP statement in SQL Server Books Online.
>goto start
... 200 occurences of the msg 976 error removed to shorten log ...
>sqlcmd -S l02-db-03 -E -i Read_Async.sql
Changed database context to 'tempdb'.
Msg 976, Level 14, State 1, Server L02-DB-03, Line 12
The target database, 'AvGroupDB1', is participating in an availability group and is currently not accessible for queries. To allow read-only access to this and other databases in the availability group, enable read access to one or more secondary availability replicas in the group. For more information, see the ALTER AVAILABILITY GROUP statement in SQL Server Books Online.
>goto start
>sqlcmd -S l02-db-03 -E -i Read_Async.sql
Changed database context to 'tempdb'.
2011-11-16 17:01:20.173: Occurence 1 has count =6
2011-11-16 17:01:20.173: Occurence 2 has count =6
2011-11-16 17:01:20.173: Occurence 3 has count =6
2011-11-16 17:01:20.173: Occurence 4 has count =6
2011-11-16 17:01:20.173: Occurence 5 has count =6
Craig | Comments Off |
Availability Group in
SQL Server 2012 

