Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with AG databases #63

Closed
wants to merge 4 commits into from

Conversation

erikdarlingdata
Copy link
Collaborator

Closes #45

@erikdarlingdata erikdarlingdata self-assigned this Oct 29, 2021
who_is_active.sql Outdated Show resolved Hide resolved
FROM sys.dm_hadr_availability_group_states AS s
WHERE s.primary_replica = r.replica_server_name
)
AND r.secondary_role_allow_connections_desc = ''READ_ONLY''
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about this logic? Reading the docs -- I don't have access to any AG servers at the moment -- I think we need to look for the string 'NO' here, not 'READ_ONLY'.

Also, I don't understand the necessity of the check on sys.dm_hadr_availability_group_states. If the current server is the primary, shouldn't that imply that the database will be readable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the logic we use in the first responder kit to avoid the errors we were hitting there when AGs were in use. I also don't currently have access to an AG for testing, and I can't recall all of the details.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I think the exists check kind of makes sense now that I look at the DMVs in more detail. It looks like availability_replicas is supposed to have the same values no matter what server you query from. So you need to go to the other view to figure out whether or how those values apply to you. Maybe? These views are really poorly designed, and this reminds me why I hate dealing with SQL Server HA stuff. Anyway, I'm going to ask the original reporter to come back with some more info before we do anything else here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error related with availability group
3 participants