Why is my SQL Server reporting CLR_AUTO_EVENT waits when I don't even use SQL CLR?
-
02-01-2021 - |
Question
When I run this query, I see high wait time for CLR_AUTO_EVENT
:
SELECT
*
FROM
sys.dm_os_wait_stats
WHERE
wait_type IN
(
'CLR_AUTO_EVENT',
'CLR_CRST',
'CLR_JOIN',
'CLR_MANUAL_EVENT',
'CLR_MEMORY_SPY',
'CLR_MONITOR',
'CLR_RWLOCK_READER',
'CLR_RWLOCK_WRITER',
'CLR_SEMAPHORE',
'CLR_TASK_START',
'CLRHOST_STATE_ACCESS',
'ASSEMBLY_LOAD',
'FS_GARBAGE_COLLECTOR_SHUTDOWN',
'SQLCLR_APPDOMAIN',
'SQLCLR_ASSEMBLY',
'SQLCLR_DEADLOCK_DETECTION',
'SQLCLR_QUANTUM_PUNISHMENT'
)
ORDER BY
wait_time_ms DESC,
wait_type ASC;
In a related question What is the SQLCLR wait type in Activity Monitor within SQL Server Management Studio (SSMS)? , I read that it appears when running .NET managed code within SQL Server.
However, I don't think I'm using any of that. When I execute EXEC sp_configure 'clr enabled'
, I see:
It looks to me like it's not even enabled. Can anybody please explain what's going on?
PS: I'm running SQL Server 2017 Developer Edition (14.0.3026.27).
Solution
SQL Server uses CLR internally for several features, and these waits track CLR background threads just sitting around waiting on a ManualResetEvent or a AutoResetEvent. According to High waits on CLR_MANUAL_EVENT and CLR_AUTO_EVENT these are background waits (ie the wait time is not happening to user sessions), and can safely be ignored unless you have unsafe CLR code using these events directly.