-
Notifications
You must be signed in to change notification settings - Fork 283
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
Conversation
who_is_active.sql
Outdated
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'' |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Closes #45