1

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;

wait types

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:

clr enabled

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).

  • Tom, please read paragraph 3 of that linked answer. I state that the "clr enabled" configuration option is only for "custom" assemblies, not anything system related. SQL Server uses CLR for several features, such as replication, change tracking, the 3 CLR datatypes (Geometry, Geography, HierarchyID), plus some of the newer built-in functions such as PARSE, TRY_PARSE, FORMAT, COMPRESS, etc. – Solomon Rutzky Jun 1 '18 at 16:32
  • @SolomonRutzky You're right, I can't believe I missed that, sorry. And thank you for the details about which features those are, it's good to know. – Tom Pažourek Jun 1 '18 at 16:34
  • 1
    Tom, no problem. And just to be clear, that was not a complete list of where CLR is being used in SQL Server. There are definitely more places. I think SSIS is one of them, plus others. I will try to add more of them to the first article in my Stairway to SQLCLR series. – Solomon Rutzky Jun 1 '18 at 17:06
4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.