Skip to content

Commit

Permalink
#2134 sp_Blitz USERSTORE_TOKENPERM check
Browse files Browse the repository at this point in the history
Adds new CheckID 233 for USERSTORE_TOKENPERM >= 10% of overall memory. Working on #2134.
  • Loading branch information
BrentOzar committed Mar 31, 2020
1 parent 9dbc4a3 commit c5eaffc
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Documentation/sp_Blitz_Checks_by_Priority.md
Expand Up @@ -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 |
|----------|-----------------------------|---------------------------------------------------------|------------------------------------------------------------------------|----------|
Expand Down Expand Up @@ -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 |
Expand Down
77 changes: 75 additions & 2 deletions sp_Blitz.sql
Expand Up @@ -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
Expand Down Expand Up @@ -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 ,
Expand All @@ -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

Expand Down

0 comments on commit c5eaffc

Please sign in to comment.