question

ClaudioGatto-2410 avatar image
0 Votes"
ClaudioGatto-2410 asked AmeliaGu-msft commented

DBCheck set up by Maint Plan fails on AG non-readable secondary

DBCheck set up by Maint Plan fails on AG non-readable secondary because DBCC CheckDB preceded by "Use <db>". Is that documented anywhere?

sql-server-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi ClaudioGatto-2410,

How are things going? Does the answer help you?
Please feel free to let us know if you have any other question.
If you find the post in the thread is helpful, you could kindly accept it as answer.

Best Regards,
Amelia

0 Votes 0 ·

1 Answer

AmeliaGu-msft avatar image
0 Votes"
AmeliaGu-msft answered

Hi ClaudioGatto-2410,
Welcome to Microsoft Q&A.
Could you please right-click the Maintenance plan->click view history to check the error message?
I do a little test, and I get the following error message:

Executing the query "USE [xxx]
" failed with the following error: "The target database, 'xxx', 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.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

If you encounter the same error message as mine, it means that the secondary replica is unreadable and the query cannot be accessed, which caused the issue. If so, please set the secondary replica to readable in primary replica:

 USE [master]
 GO
 ALTER AVAILABILITY GROUP [groupname]
 MODIFY REPLICA ON N'replicaname' WITH (SECONDARY_ROLE(ALLOW_CONNECTIONS = ALL))
 GO

Please refer to this doc which might be helpful.

If you have any question, please feel free to let us know.

Best Regards,
Amelia


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.