About Me

My photo
I am MCSE in Data Management and Analytics with specialization in MS SQL Server and MCP in Azure. I have over 13+ years of experience in IT industry with expertise in data management, Azure Cloud, Data-Canter Migration, Infrastructure Architecture planning and Virtualization and automation. Contact me if you are looking for any sort of guidance in getting your Infrastructure provisioning automated through Terraform. I sometime write for a place to store my own experiences for future search and read by own blog but can hopefully help others along the way. Thanks.

Unable to access availability database 'XXXX' because the database replica is not in the PRIMARY or SECONDARY role.


Issue:- Sometime issue comes like, when you try to access a database in AlwaysOn it gives error like "Unable to access availability database 'AdventureWorks2014' because the database replica is not in the PRIMARY or SECONDARY role. Connections to an availability database is permitted only when the database replica is in the PRIMARY or SECONDARY role. Try the operation again later. "
Error: 983


When you try to expand AlwaysOn High Availability Folder it will not expand..



TITLE: Microsoft SQL Server Management Studio
------------------------------
Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Unable to access availability database 'AdventureWorks2014' because the database replica is not in the PRIMARY or SECONDARY role. Connections to an availability database is permitted only when the database replica is in the PRIMARY or SECONDARY role. Try the operation again later. (Microsoft SQL Server, Error: 983)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=13.00.4001&EvtSrc=MSSQLServer&EvtID=983&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------


Troubleshooting steps:- In order to troubleshoot this issue..
Go to 
1. Cluster Administrator on same Node
2. Connect to the Cluster
3.Ensure you are connecting to correct clusterName
4. In my case Cluster core group resources was down as shown in below image.
5  Try to bring Cluster core group resource online.


6. if Cluster core resources start immediately its fine, proceed with step 7, otherwise check check  clusterevent
below error may be appearing..
The cluster Resource Hosting Subsystem (RHS) process was terminated and will be restarted. This is typically associated with cluster health detection and recovery of a resource. Refer to the System event log to determine which resource and resource DLL is causing the issue.


Now we will check system event viewer for error like why it gave error like Failed to bring the resource 'Cluster Name' online.

when i checked system event viewer i got below error..

Error No : 10028


Description:
DCOM was unable to communicate with the computer Win2k12Cluster.Adven.com using any of the configured protocols; requested by PID      ae4 (C:\Windows\system32\ServerManager.exe).


Before troubleshooting Error No 10028, check if all nodes in cluster are pinging from each other or not.
Restart Cluster service of all nodes.

in my case when i tried to restart cluster service i got below error..


This indicate Cluster service on my 2nd node is not coming up.

when i see eventviewer.system i get below error message again..
DCOM was unable to communicate with the computer Win2k12Cluster.Adven.com using any of the configured protocols; requested by PID      ae4 (C:\Windows\system32\ServerManager.exe).

 Resolution:-


  1. Click Start, and then click Run.
  2. Type wf.msc, and then click OK. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
  3. In the console tree, click Inbound rules.
  4. In the list of firewall exception rules, look for COM+ Network Access (DCOM In).
  5. If the firewall exception rule is not enabled, in the details pane click Enable rule, and then scroll horizontally to confirm that the protocol is TCP and the LocalPort is 135. 
  6. Close Windows Firewall with Advanced Security.


Then kill the clussvc.exe  from task manager

I did repeat the same on another 2 nodes of cluster.

and then i was able to bring cluster core group resoources online and AlwaysOn Availability group online.


This is how i did resolve this issue. it looks Cluster service of one of node gone exhausted and even after restart it was not coming up, so the approach was just to restart 2nd node of Cluster service, it looks after successful restart of 2nd node Cluster service and later everything came up.


Thanks for Reading..