lowCLR

CLR_AUTO_EVENT Wait Type Explained

CLR_AUTO_EVENT is a benign SQL Server wait type from .NET runtime background operations. Learn why to filter this harmless wait from performance analysis.

Quick Answer

CLR_AUTO_EVENT occurs when SQL Server's internal CLR tasks wait on .NET Framework autoevent signaling during background operations. This is a completely benign wait type that represents normal CLR runtime housekeeping and should always be filtered from wait statistics analysis.

Root Cause Analysis

CLR_AUTO_EVENT waits originate from SQL Server's hosting of the .NET Common Language Runtime within the database engine process. When SQL Server loads the CLR subsystem (even without user CLR code), internal .NET Framework background threads perform garbage collection, assembly management, and runtime maintenance tasks. These operations use Win32 autoevent objects for thread synchronization.

The wait appears when CLR worker threads call WaitForSingleObject() or WaitForMultipleObjects() on autoevent handles during normal .NET runtime operations. The SQL Server scheduler tracks these waits because CLR threads integrate with the SQL OS cooperative scheduling model, but the waits represent necessary .NET runtime overhead rather than database workload.

This behavior exists across all SQL Server versions supporting CLR integration (2005+) and remains consistent through SQL Server 2022. The wait duration varies based on .NET Framework garbage collection patterns and CLR assembly lifecycle management, which explains why Microsoft states "long waits are typical."

Even databases without user-defined CLR objects generate these waits because SQL Server always initializes the CLR subsystem for internal functionality like spatial data types and XML processing.

AutoDBA checks Benign wait filtering, actionable wait type identification, and CLR performance monitoring across your entire SQL Server instance in 60 seconds. Download the free diagnostic script and see what else needs attention.

Diagnostic Queries

-- Verify CLR_AUTO_EVENT is present but not performance-impacting
SELECT 
    wait_type,
    waiting_tasks_count,
    wait_time_ms,
    max_wait_time_ms,
    signal_wait_time_ms,
    wait_time_ms / NULLIF(waiting_tasks_count, 0) AS avg_wait_ms
FROM sys.dm_os_wait_stats 
WHERE wait_type = 'CLR_AUTO_EVENT';

-- Show wait stats excluding all benign waits including CLR_AUTO_EVENT
SELECT 
    wait_type,
    wait_time_ms,
    percentage = CAST(100.0 * wait_time_ms / SUM(wait_time_ms) OVER() AS DECIMAL(5,2))
FROM sys.dm_os_wait_stats
WHERE wait_type NOT IN (
    'BROKER_EVENTHANDLER', 'BROKER_RECEIVE_WAITFOR', 'BROKER_TASK_STOP',
    'BROKER_TO_FLUSH', 'BROKER_TRANSMITTER', 'CHECKPOINT_QUEUE',
    'CHKPT', 'CLR_AUTO_EVENT', 'CLR_MANUAL_EVENT', 'CLR_SEMAPHORE',
    'DBMIRROR_DBM_EVENT', 'DBMIRROR_EVENTS_QUEUE', 'DBMIRROR_WORKER_QUEUE',
    'DBMIRRORING_CMD', 'DIRTY_PAGE_POLL', 'DISPATCHER_QUEUE_SEMAPHORE',
    'EXECSYNC', 'FSAGENT', 'FT_IFTS_SCHEDULER_IDLE_WAIT', 'FT_IFTSHC_MUTEX',
    'HADR_CLUSAPI_CALL', 'HADR_FILESTREAM_IOMGR_IOCOMPLETION', 'HADR_LOGCAPTURE_WAIT',
    'HADR_NOTIFICATION_DEQUEUE', 'HADR_TIMER_TASK', 'HADR_WORK_QUEUE',
    'KSOURCE_WAKEUP', 'LAZYWRITER_SLEEP', 'LOGMGR_QUEUE', 'ONDEMAND_TASK_QUEUE',
    'PWAIT_ALL_COMPONENTS_INITIALIZED', 'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP',
    'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP', 'REQUEST_FOR_DEADLOCK_SEARCH',
    'RESOURCE_QUEUE', 'SERVER_IDLE_CHECK', 'SLEEP_BPOOL_FLUSH', 'SLEEP_DBSTARTUP',
    'SLEEP_DCOMSTARTUP', 'SLEEP_MASTERDBREADY', 'SLEEP_MASTERMDREADY',
    'SLEEP_MASTERUPGRADED', 'SLEEP_MSDBSTARTUP', 'SLEEP_SYSTEMTASK', 'SLEEP_TASK',
    'SLEEP_TEMPDBSTARTUP', 'SNI_HTTP_ACCEPT', 'SP_SERVER_DIAGNOSTICS_SLEEP',
    'SQLTRACE_BUFFER_FLUSH', 'SQLTRACE_INCREMENTAL_FLUSH_SLEEP',
    'SQLTRACE_WAIT_ENTRIES', 'WAIT_FOR_RESULTS', 'WAITFOR', 'WAITFOR_TASKSHUTDOWN',
    'WAIT_XTP_HOST_WAIT', 'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', 'WAIT_XTP_CKPT_CLOSE',
    'XE_DISPATCHER_JOIN', 'XE_DISPATCHER_WAIT', 'XE_TIMER_EVENT'
)
AND wait_time_ms > 0
ORDER BY wait_time_ms DESC;

Prevention

No prevention is required or recommended for CLR_AUTO_EVENT waits. These waits represent essential .NET runtime operations that occur regardless of user CLR usage. Attempting to disable CLR integration to eliminate these waits would break SQL Server functionality for spatial data types, XML features, and other internal components.

Focus performance monitoring efforts on actionable wait types like PAGEIOLATCH_SH, CXPACKET, or LCK_M_* waits that indicate actual resource contention. Modern monitoring tools like AutoDBA automatically filter benign waits including CLR_AUTO_EVENT so DBAs receive alerts only for performance-impacting conditions.

Need hands-on help?

Dealing with persistent clr_auto_event issues across your environment? Samix Technology provides hands-on SQL Server performance consulting with 15+ years of production DBA experience.

Related Pages