BrentOzarULTD / SQL-Server-First-Responder-Kit

sp_Blitz, sp_BlitzCache, sp_BlitzFirst, sp_BlitzIndex, and other SQL Server scripts for health checks and performance tuning.
http://FirstResponderKit.org
Other
3.38k stars 1k forks source link

sp_Blitz: Check 191 - 'Mismatch between the number of TempDB files in sys.master_files versus tempdb.sys.database_files' falsely reported when run without sysadmin #3578

Closed Tisit closed 1 month ago

Tisit commented 1 month ago

Version of the script 8.21 - top Github commit

What is the current behavior? Check 191 - 'Mismatch between the number of TempDB files in sys.master_files versus tempdb.sys.database_files' falsely reported when run without sysadmin permission

If the current behavior is a bug, please provide the steps to reproduce. Run sp_Blitz with user having securityadmin and VIEW SERVER STATE permissions -> Check is always reported Running sp_Blitz with sysadmin -> Check is not reported, unless there is a real mismatch

What is the expected behavior? The check is skipped when user cannot properly read sys.master_files table

Which versions of SQL Server and which OS are affected by this issue? Did this work in previous versions of our procedures? I'm sure this affects any SQL Server version, but I'm using following: Microsoft SQL Server 2019 (RTM-CU25-GDR) (KB5036335) - 15.0.4360.2 (X64) Mar 19 2024 00:23:01 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Pro 10.0 (Build 19045: )

############################################

Regarding your comment from my pull request: I couldn't find a situation where row count from sys.master_files < tempdb.sys.database_files and sys.master_files > 0. But granted I didn't look for long. I will try reworking the fix according to your suggestion.

BrentOzar commented 1 month ago

Thanks for the pull request! Looks good, merging into the dev branch, will be in the October release with credit to you in the release notes.