Error: 983, Severity: 14, State: 1;Unable to access availability database 'xxxx' because the database replica is not in the PRIMARY or SECONDARY role.



There is an error occurred on Always On High availability Environment  today. There are two nodes One primary replica and another is Secondary replica. Assume here A is Primary replica and B is a secondary replica. Windows team has a plan to update NET BIOS. So they want do the update on Secondary node(B) which is acting as secondary replica now.  So every database is in Synchronized State in secondary replica(B) because  AG configured as Synchronous Commit.  After NET BIOS update windows team started the services.
Being a DBA, we need to monitor and do the fail over. Once services are started in Secondary replica(B) databases started coming to Synchronized state one by one. There is a database called Orders is taking time as its size is near 1 TB.  After an hour of waiting even this database come to Synchronized state and as usual it Secondary replica now(B) because we hit the secondary replica first.
Now we want to do the same update in Primary replica too(A). So we went to primary replica do the fail over to B(which is acting as  a SECONDARY REPLICA at this moment) and started the fail over and it went smoothly but the when I look at the database status, except Orders  database all other databases came  to Synchronized and B replica is in NOT SYNCHRONIZING state and  even in secondary replica(Now A is secondary  replica) Order database is in NOT SYNCHRONIZING state. In both the  replica B which is acting as Primary now and A which is acting as Secondary now. In  both nodes database is in NOT SYNCHRONIZING state. And  under availability  group side in both the replicas database status is in RED. 
And if I see in error log ( in B server which is acting as Primary  now).  I  found below error.

Error: 983, Severity: 14, State: 1.
2018-09-29 05:32:40.570 Logon 
Unable to access availability database 'DatabaseName' 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.

Solution: And I run the below  command to bring this database online state in Primary replica(B which is acting  now)

USE  master
GO
ALTER DATABASE  DatabaseName
SET ONLINE

Comments

Popular posts from this blog

System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out

Pre login Handshake or Connection Timeout Period

Transparent Data Encryption(TDE) with Master Key and Certificate in SQL Server