Skip to content

Commit 871122d

Browse files
authored
Merge pull request #2448 from BrentOzarULTD/2134_sp_BlitzFirst_UserStoreTokenPerm
#2134 sp_BlitzFirst check for UserStore_TokenPerm leak
2 parents c63b8df + 6f7bca6 commit 871122d

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

Documentation/sp_BlitzFirst_Checks_by_Priority.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Before adding a new check, make sure to add a Github issue for it first, and hav
66

77
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.
88

9-
CURRENT HIGH CHECKID: 44
10-
If you want to add a new check, start at 45
9+
CURRENT HIGH CHECKID: 45
10+
If you want to add a new check, start at 46
1111

1212
| Priority | FindingsGroup | Finding | URL | CheckID |
1313
|----------|---------------------------------|---------------------------------------|-------------------------------------------------|----------|
@@ -29,6 +29,7 @@ If you want to add a new check, start at 45
2929
| 50 | In-Memory OLTP | Garbage Collection in Progress | https://BrentOzar.com/go/garbage | 31 |
3030
| 50 | Query Problems | Compilations/Sec High | https://BrentOzar.com/go/compile | 15 |
3131
| 50 | Query Problems | Implicit Transactions | https://www.brentozar.com/go/ImplicitTransactions/ | 37 |
32+
| 50 | Query Problems | Memory Leak in USERSTORE_TOKENPERM Cache | https://BrentOzar.com/go/userstore | 45 |
3233
| 50 | Query Problems | Plan Cache Erased Recently | https://BrentOzar.com/go/freeproccache | 7 |
3334
| 50 | Query Problems | Re-Compilations/Sec High | https://BrentOzar.com/go/recompile | 16 |
3435
| 50 | Query Problems | Statistics Updated Recently | https://BrentOzar.com/go/stats | 44 |

sp_BlitzFirst.sql

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,46 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
17951795
'http://www.BrentOzar.com/askbrent/' AS URL
17961796
FROM sys.dm_exec_query_memory_grants AS Grants;
17971797

1798+
/* Query Problems - Memory Leak in USERSTORE_TOKENPERM Cache */
1799+
IF EXISTS (SELECT * FROM sys.all_columns WHERE object_id = OBJECT_ID('sys.dm_os_memory_clerks') AND name = 'pages_kb')
1800+
BEGIN
1801+
/* SQL 2012+ version */
1802+
SET @StringToExecute = N'
1803+
INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, Details, URL)
1804+
SELECT 45 AS CheckID,
1805+
50 AS Priority,
1806+
''Query Problems'' AS FindingsGroup,
1807+
''Memory Leak in USERSTORE_TOKENPERM Cache'' AS Finding,
1808+
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))
1809+
+ N''GB RAM, total buffer pool is '' + CAST(CAST(SUM(pages_kb) / 1024.0 / 1024.0 AS INT) AS NVARCHAR(100)) + N''GB.''
1810+
AS details,
1811+
''https://www.BrentOzar.com/go/userstore'' AS URL
1812+
FROM sys.dm_os_memory_clerks
1813+
HAVING SUM(CASE WHEN type = ''USERSTORE_TOKENPERM'' AND name = ''TokenAndPermUserStore'' THEN pages_kb * 1.0 ELSE 0.0 END) / SUM(pages_kb) >= 0.1
1814+
AND SUM(pages_kb) / 1024.0 / 1024.0 >= 1; /* At least 1GB RAM overall */';
1815+
EXEC sp_executesql @StringToExecute;
1816+
END
1817+
ELSE
1818+
BEGIN
1819+
/* Antiques Roadshow SQL 2008R2 - version */
1820+
SET @StringToExecute = N'
1821+
INSERT INTO #BlitzResults (CheckID, Priority, FindingsGroup, Finding, Details, URL)
1822+
SELECT 45 AS CheckID,
1823+
50 AS Priority,
1824+
''Performance'' AS FindingsGroup,
1825+
''Memory Leak in USERSTORE_TOKENPERM Cache'' AS Finding,
1826+
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))
1827+
+ 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.''
1828+
AS details,
1829+
''https://www.BrentOzar.com/go/userstore'' AS URL
1830+
FROM sys.dm_os_memory_clerks
1831+
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
1832+
AND SUM(single_pages_kb + multi_pages_kb) / 1024.0 / 1024.0 >= 1; /* At least 1GB RAM overall */';
1833+
EXEC sp_executesql @StringToExecute;
1834+
END
1835+
1836+
1837+
17981838
IF @Seconds > 0
17991839
BEGIN
18001840

0 commit comments

Comments
 (0)