-> I was trying to add a new database to availability group an got below error,
TITLE: Microsoft SQL Server Management Studio
Failed to join the database ‘JBDB’ to the availability group ‘JBSAG’ on the availability replica ‘JBSAG2’. (Microsoft.SqlServer.Management.HadrModel)
For help, click: https://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=16.100.37971.0&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&LinkId=20476
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
The connection to the primary replica is not active. The command cannot be processed. (Microsoft SQL Server, Error: 35250)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=14.00.3294&EvtSrc=MSSQLServer&EvtID=35250&LinkId=20476
-> Executing below code to check if endpoint is started on all nodes in SQLCMD mode,
:Connect JBSAG1 select name, state_desc, port from sys.tcp_endpoints where type_desc='DATABASE_MIRRORING' go :Connect JBSAG2 select name, state_desc, port from sys.tcp_endpoints where type_desc='DATABASE_MIRRORING' go :Connect JBSAG3 select name, state_desc, port from sys.tcp_endpoints where type_desc='DATABASE_MIRRORING' go
-> Endpoint on JBSAG2 is down.
-> I have started it with below code in SQLCMD mode,
:Connect JBSAG2 alter endpoint [Hadr_endpoint] state = started go
-> Adding database to Availability group works fine without issues after above fix.
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.