diff --git a/Documentation/sp_Blitz_Checks_by_Priority.md b/Documentation/sp_Blitz_Checks_by_Priority.md index b035d0ab5..efd026d9c 100644 --- a/Documentation/sp_Blitz_Checks_by_Priority.md +++ b/Documentation/sp_Blitz_Checks_by_Priority.md @@ -6,8 +6,8 @@ Before adding a new check, make sure to add a Github issue for it first, and hav If you want to change anything about a check - the priority, finding, URL, or ID - open a Github issue first. The relevant scripts have to be updated too. -CURRENT HIGH CHECKID: 232. -If you want to add a new one, start at 233. +CURRENT HIGH CHECKID: 233. +If you want to add a new one, start at 234. | Priority | FindingsGroup | Finding | URL | CheckID | |----------|-----------------------------|---------------------------------------------------------|------------------------------------------------------------------------|----------| @@ -55,6 +55,7 @@ If you want to add a new one, start at 233. | 50 | DBCC Events | Overall Events | https://www.BrentOzar.com/go/dbcc | 203 | | 50 | Performance | File Growths Slow | https://www.BrentOzar.com/go/filegrowth | 151 | | 50 | Performance | Instant File Initialization Not Enabled | https://www.BrentOzar.com/go/instant | 192 | +| 50 | Performance | Memory Leak in USERSTORE_TOKENPERM Cache | https://www.BrentOzar.com/go/userstore| 233 | | 50 | Performance | Poison Wait Detected | https://www.BrentOzar.com/go/poison | 107 | | 50 | Performance | Poison Wait Detected: CMEMTHREAD & NUMA | https://www.BrentOzar.com/go/poison | 162 | | 50 | Performance | Poison Wait Detected: Serializable Locking | https://www.BrentOzar.com/go/serializable | 121 | diff --git a/sp_Blitz.sql b/sp_Blitz.sql index 488bc1af3..a4d6f9c5e 100644 --- a/sp_Blitz.sql +++ b/sp_Blitz.sql @@ -5712,7 +5712,7 @@ IF @ProductVersionMajor >= 10 WHERE DatabaseName IS NULL AND CheckID = 221 ) BEGIN - IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 216) WITH NOWAIT; + IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 221) WITH NOWAIT; WITH reboot_airhorn AS @@ -5750,7 +5750,7 @@ IF @ProductVersionMajor >= 10 AND CAST(SERVERPROPERTY('Edition') AS NVARCHAR(4000)) LIKE '%Evaluation%' BEGIN - IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 216) WITH NOWAIT; + IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 229) WITH NOWAIT; INSERT INTO #BlitzResults ( CheckID , @@ -5772,6 +5772,79 @@ IF @ProductVersionMajor >= 10 END; + + + + IF NOT EXISTS ( SELECT 1 + FROM #SkipChecks + WHERE DatabaseName IS NULL AND CheckID = 233 ) + BEGIN + + IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 233) WITH NOWAIT; + + + IF EXISTS (SELECT * FROM sys.all_columns WHERE object_id = OBJECT_ID('sys.dm_os_memory_clerks') AND name = 'pages_kb') + BEGIN + /* SQL 2012+ version */ + SET @StringToExecute = N' + INSERT INTO #BlitzResults + ( CheckID , + Priority , + FindingsGroup , + Finding , + URL , + Details + ) + SELECT 233 AS CheckID, + 50 AS Priority, + ''Performance'' AS FindingsGroup, + ''Memory Leak in USERSTORE_TOKENPERM Cache'' AS Finding, + ''https://www.BrentOzar.com/go/userstore'' AS URL, + N''UserStore_TokenPerm clerk is using '' + CAST(CAST(SUM(CASE WHEN type = ''USERSTORE_TOKENPERM'' AND name = ''TokenAndPermUserStore'' THEN pages_kb * 1.0 ELSE 0.0 END) / 1024.0 / 1024.0 AS INT) AS NVARCHAR(100)) + + N''GB RAM, total buffer pool is '' + CAST(CAST(SUM(pages_kb) / 1024.0 / 1024.0 AS INT) AS NVARCHAR(100)) + N''GB.'' + AS details + FROM sys.dm_os_memory_clerks + HAVING SUM(CASE WHEN type = ''USERSTORE_TOKENPERM'' AND name = ''TokenAndPermUserStore'' THEN pages_kb * 1.0 ELSE 0.0 END) / SUM(pages_kb) >= 0.1 + AND SUM(pages_kb) / 1024.0 / 1024.0 >= 1; /* At least 1GB RAM overall */'; + EXEC sp_executesql @StringToExecute; + END + ELSE + BEGIN + /* Antiques Roadshow SQL 2008R2 - version */ + SET @StringToExecute = N' + INSERT INTO #BlitzResults + ( CheckID , + Priority , + FindingsGroup , + Finding , + URL , + Details + ) + SELECT 233 AS CheckID, + 50 AS Priority, + ''Performance'' AS FindingsGroup, + ''Memory Leak in USERSTORE_TOKENPERM Cache'' AS Finding, + ''https://www.BrentOzar.com/go/userstore'' AS URL, + N''UserStore_TokenPerm clerk is using '' + CAST(CAST(SUM(CASE WHEN type = ''USERSTORE_TOKENPERM'' AND name = ''TokenAndPermUserStore'' THEN single_pages_kb + multi_pages_kb * 1.0 ELSE 0.0 END) / 1024.0 / 1024.0 AS INT) AS NVARCHAR(100)) + + N''GB RAM, total buffer pool is '' + CAST(CAST(SUM(single_pages_kb + multi_pages_kb) / 1024.0 / 1024.0 AS INT) AS NVARCHAR(100)) + N''GB.'' + AS details + FROM sys.dm_‰os_memory_clerks + HAVING SUM(CASE WHEN type = ''USERSTORE_TOKENPERM'' AND name = ''TokenAndPermUserStore'' THEN single_pages_kb + multi_pages_kb * 1.0 ELSE 0.0 END) / SUM(single_pages_kb + multi_pages_kb) >= 0.1 + AND SUM(single_pages_kb + multi_pages_kb) / 1024.0 / 1024.0 >= 1; /* At least 1GB RAM overall */'; + EXEC sp_executesql @StringToExecute; + END + + END; + + + + + + + + + + IF @CheckUserDatabaseObjects = 1 BEGIN