Database Management

SQL Sentry - Availability Replica errors in logs

The rolling logs are getting inundated with availability replica errors.

First published date

12/11/2023 4:54 PM

Last published date

2/20/2025 11:11 PM

Overview

The following errors might fill in rolling-log.txt and rolling-log-perfcollection.txt:

<Timestamp> [WIN22-SQL22-R1.MYTEST.INT Performance Monitor] ERROR SqlSentry.Server.Windows.DataCollectors.SqlServerDataCollector [(null)] - SetFileUsedSize unable to access the database:[MyDB_DAG] on target:[WIN22-SQL22-R1.MYTEST.INT] despite it being online; or, another error has occurred.
System.Data.SqlClient.SqlException (0x80131904): The target database, 'MyDB_DAG', is participating in an availability group and is currently not accessible for queries. Either data movement is suspended or the availability replica is not enabled for read access. 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.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
   at SentryOne.Data.SqlHelper.ExecuteReader(SqlConnection connection, SqlTransaction transaction, CommandType commandType, String commandText, SqlParameter[] commandParameters, SqlConnectionOwnership connectionOwnership, Int32 commandTimeout)
   at SentryOne.Data.SqlHelper.ExecuteReader(Int32 commandTimeout, String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters)
   at SqlSentry.Server.Windows.DataCollectors.SqlServerDataCollector.SetFileUsedSize(PerformanceAnalysisSqlFileAccessor file, Dictionary`2 databasesByID)
ClientConnectionId:8597a413-4183-4e22-8a37-f04cd81f7c0a
Error Number:976,State:1,Class:14

Product section

SQL Sentry (SQLS)

Cause

One of the SQL Sentry queries only considers the [state] of the database and not any considerations of it being a part of an AG.

Resolution

Upgrade to 2023.4 or higher. The affected query has since been updated to be AG-aware.