pull request for issue #162 - move all AG related queries to AlwaysOnDiagScript.sql#177
pull request for issue #162 - move all AG related queries to AlwaysOnDiagScript.sql#177PiJoCoder merged 10 commits intomicrosoft:masterfrom
Conversation
+ first draft of making AlwaysOnDiagScript.sql dynamic SQL ,choosing columns per version. -missing points *confirm columns *import tests on Nexus side *add rowset definitions
working on the AlwaysOnDiagScript.sql modification for issue microsoft#162
DiagManager/CustomDiagnostics/AlwaysOn Basic Info/AlwaysOnDiagScript.sql
Outdated
Show resolved
Hide resolved
DiagManager/CustomDiagnostics/AlwaysOn Basic Info/AlwaysOnDiagScript.sql
Outdated
Show resolved
Hide resolved
DiagManager/CustomDiagnostics/AlwaysOn Basic Info/AlwaysOnDiagScript.sql
Outdated
Show resolved
Hide resolved
DiagManager/CustomDiagnostics/AlwaysOn Basic Info/AlwaysOnDiagScript.sql
Outdated
Show resolved
Hide resolved
DiagManager/CustomDiagnostics/AlwaysOn Basic Info/AlwaysOnDiagScript.sql
Outdated
Show resolved
Hide resolved
DiagManager/CustomDiagnostics/AlwaysOn Basic Info/AlwaysOnDiagScript.sql
Outdated
Show resolved
Hide resolved
DiagManager/CustomDiagnostics/AlwaysOn Basic Info/AlwaysOnDiagScript.sql
Outdated
Show resolved
Hide resolved
DiagManager/CustomDiagnostics/AlwaysOn Basic Info/AlwaysOnDiagScript.sql
Outdated
Show resolved
Hide resolved
DiagManager/CustomDiagnostics/AlwaysOn Basic Info/AlwaysOnDiagScript.sql
Outdated
Show resolved
Hide resolved
DiagManager/CustomDiagnostics/AlwaysOn Basic Info/AlwaysOnDiagScript.sql
Outdated
Show resolved
Hide resolved
DiagManager/CustomDiagnostics/AlwaysOn Basic Info/AlwaysOnDiagScript.sql
Outdated
Show resolved
Hide resolved
| IF (@sql_major_version >=14) --this exists SQL 2017 and above | ||
| BEGIN | ||
| SET @sql = @sql + ',is_distributed_network_name' | ||
| END |
There was a problem hiding this comment.
I ran the script on a SQL 2019 and got this error:
-- AG_hadr_ag_listeners --
Msg 207, Level 16, State 1, Server NODE1LABCSS\SQL2019, Line 1
Invalid column name 'is_distributed_network_name'.
Then ran `select * from sys.availability_group_listeners` and don't see this column. The suggestion is to remove this logic or double-check it and make sure it applies to this DMV
| IF (@sql_major_version >=14) --this exists SQL 2017 and above | |
| BEGIN | |
| SET @sql = @sql + ',is_distributed_network_name' | |
| END |
There was a problem hiding this comment.
Thank you @PiJoCoder , I see this is not there on the RTM and added later in the CUs and not failed for me since I have those CUs on my test box. I will modify the logic to check the builds as well per major version.
https://docs.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/availability-group-distributed-network-name-dnn-listener-configure?view=azuresql
There was a problem hiding this comment.
Oh, @hacitandogan I see, it is the SYS.AVAILABILITY_GROUP_LISTENERS DMV that has this. I do have it on my SQL 2019 build, but was querying the sys.availability_groups instead incorrectly. And since the documentation does not include the column, I didn't know which one had it. Can you fully-qualify the column to help with this discovery - ag1.is_distributed_network_name? And perhaps for consistency these columns too: listener_id,dns_name,port,is_conformant,ip_configuration_string_from_cluster
Thank you
There was a problem hiding this comment.
@PiJoCoder , thank you , I modified this to make names full-qualified for those columns and added the additional build check logic for is_distributed_network_name column.
--this column exists SQL 2019 CU8 ,SQL 2017 CU25,SQL 2016 SP3 and above
There was a problem hiding this comment.
--this column exists SQL 2019 CU8 ,SQL 2017 CU25,SQL 2016 SP3 and above
Thanks for calling these out. Based on these, submitted an update request on
https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-availability-group-listeners-transact-sql?view=sql-server-ver16
|
|
||
| $expectedFileAttributes = @( | ||
| [PSCustomObject]@{Algorithm = "SHA512"; Hash = "5AC4409C459ACB9778E2731E641C517FDE86BAD84B5E9EA5DA3B09127578A3AA01D5AF2A9FCB3A2208B919E5D940E8B971A555DCCFCF7969D3740D01BDB5E513"; FileName = ".\AlwaysOnDiagScript.sql"; FileSize = 11905} | ||
| [PSCustomObject]@{Algorithm = "SHA512"; Hash = "769E5354390EECB184B23C1D4D212424185FF636F25AEE244E85C0BC82717136124A32EBEE7F53ABA238E9301974A62729F7B6097DCC6AD89204050AD90218F9"; FileName = ".\AlwaysOnDiagScript.sql"; FileSize = 19876} |
There was a problem hiding this comment.
| [PSCustomObject]@{Algorithm = "SHA512"; Hash = "769E5354390EECB184B23C1D4D212424185FF636F25AEE244E85C0BC82717136124A32EBEE7F53ABA238E9301974A62729F7B6097DCC6AD89204050AD90218F9"; FileName = ".\AlwaysOnDiagScript.sql"; FileSize = 19876} | |
| [PSCustomObject]@{Algorithm = "SHA512"; Hash = "1E98F8BC77D9F6952CB83C87780BEF0D61F40D243AF52C532DFE5C79FE0559EF230585230E32D1D0D5159FCB9651C56A823C35FD5BBB4A25571D528EC6C45E1A"; FileName = ".\AlwaysOnDiagScript.sql"; FileSize = 19898} |
|
@hacitandogan , thank you for all your work on this. We made a small change where we added spaces in the rowset identifiers. Could you please create rowset identifiers for these. Perhaps the person who created them didn't realize those get imported in SQL Nexus. These probably never got imported in the first place. Also, could you please remove these "headings". They do add some value in that they explain what the rowset is about, but people rarely read the raw file, and if they do, these headings actually make it harder to read the rowset content. So please remove them and replace them with regular rowset identifiers. Thank you |
|
@hacitandogan , could you also sync your forked repo with recent changes from the upstream repo. Go to Fetch Upstream and sync your Forked repo. Then pull the changes down to your local machine (git pull) |
-added build check for is_distributed_network_name column -added missing identifiers for xevent data -removed headings -other minor modifications
|
@PiJoCoder , thank you for all the feedbacks. I did following modifications; |
Great! I am testing these now. |
|
@hacitandogan one thing that I am discovering - in AG_AlwaysOn_health_availability_replica_manager_state_change output there could be a ton of rows. In fact the AG I just tested against returned over 5200 rows. Do you think we should get the latest 500 or something like that? Some limited number....? |
-limited the row counts to TOP 500 for AlwaysOn_health* events -changed date order to DESC to get latest records
|
Thank you @PiJoCoder , just checked these numbers on my side and I see similar row numbers even on my test box. |
recalculate the hash for AlwaysOnDiagScript.sql
Yes, this is good. At least we won't get a ton of rows that we don't need and bloat the output files. |
|
Thank you @hacitandogan ! Looks great - merged! |


Fixes #162
Changes proposed in this pull request:
clearing the duplicates from MiscPssdiaginfo.sql and SQL Server Perf Stats Snapshot.sql and combining all AG related queries under AlwaysOnDiagScript.sql
How to test this code:
Has been tested on (remove any that don't apply):