Quick Answer
BROKER_INIT waits occur when SQL Server initializes Service Broker components in databases where Service Broker is enabled. These waits typically appear during database startup, failover scenarios, or when Service Broker is first enabled on a database. While normally brief and infrequent, persistent BROKER_INIT waits indicate Service Broker initialization problems.
Root Cause Analysis
BROKER_INIT waits happen during the Service Broker subsystem initialization phase within the database engine. When a database comes online, SQL Server's Service Broker manager must initialize message queues, routes, services, and conversation endpoints for each database where Service Broker is enabled (is_broker_enabled = 1).
The initialization process involves several internal components working sequentially. The Service Broker manager coordinates with the lock manager to establish exclusive locks on system metadata tables, the buffer pool manager to load Service Broker configuration data into memory, and the scheduler to allocate worker threads for message processing. During this phase, any thread attempting to access Service Broker functionality waits on BROKER_INIT.
SQL Server 2016 introduced improvements to Service Broker initialization that reduced the duration of these waits by parallelizing certain initialization tasks. SQL Server 2019 further optimized the process by implementing lazy initialization for conversation endpoints, meaning they initialize only when first accessed rather than during database startup. SQL Server 2022 enhanced the initialization error handling, providing more granular wait statistics and better diagnostic information when initialization fails.
The wait becomes problematic when databases have large numbers of Service Broker objects (thousands of queues or services), corrupted Service Broker metadata, or when the tempdb is under severe pressure during startup. In Always On configurations, BROKER_INIT waits are common during failover events as the new primary replica initializes Service Broker for all databases simultaneously.
AutoDBA checks Service Broker configuration, initialization monitoring, and database startup optimization across your entire SQL Server instance in 60 seconds. Download the free diagnostic script and see what else needs attention.
Diagnostic Queries
-- Check Service Broker status and initialization state
SELECT
d.name AS database_name,
d.is_broker_enabled,
d.service_broker_guid,
d.is_trustworthy_on
FROM sys.databases d
WHERE d.is_broker_enabled = 1;
-- Identify current BROKER_INIT waits and blocking
SELECT
session_id,
wait_type,
wait_time_ms,
blocking_session_id,
wait_resource,
command,
database_id,
DB_NAME(database_id) AS database_name
FROM sys.dm_exec_requests
WHERE wait_type = 'BROKER_INIT'
ORDER BY wait_time_ms DESC;
-- Analyze Service Broker object counts in the current database
SELECT
OBJECT_SCHEMA_NAME(object_id) AS schema_name,
name AS queue_name,
is_activation_enabled,
is_poison_message_handling_enabled
FROM sys.service_queues
ORDER BY name;
-- Check for Service Broker errors in error log
EXEC xp_readerrorlog 0, 1, N'Service Broker';
-- Monitor historical BROKER_INIT wait statistics
SELECT
wait_type,
waiting_tasks_count,
wait_time_ms,
max_wait_time_ms,
signal_wait_time_ms,
wait_time_ms - signal_wait_time_ms AS resource_wait_time_ms
FROM sys.dm_os_wait_stats
WHERE wait_type = 'BROKER_INIT';
Fix Scripts
Disable Service Broker on unused databases This script identifies and disables Service Broker on databases where it's enabled but not actively used, eliminating unnecessary initialization overhead.
-- WARNING: Test in development first. Disabling Service Broker drops all queues and services
USE master;
GO
DECLARE @sql NVARCHAR(MAX) = '';
DECLARE @dbname SYSNAME;
DECLARE db_cursor CURSOR FOR
SELECT d.name
FROM sys.databases d
WHERE d.is_broker_enabled = 1
AND d.database_id > 4 -- Skip system databases
AND d.name NOT IN ('msdb');
OPEN db_cursor;
FETCH NEXT FROM db_cursor INTO @dbname;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @sql = 'ALTER DATABASE [' + @dbname + '] SET DISABLE_BROKER;';
PRINT @sql;
-- EXEC sp_executesql @sql; -- Uncomment after testing
FETCH NEXT FROM db_cursor INTO @dbname;
END
CLOSE db_cursor;
DEALLOCATE db_cursor;
Force Service Broker reinitialization When Service Broker initialization is stuck or corrupted, forcing a reinitialization can resolve persistent BROKER_INIT waits.
-- Use with extreme caution: This breaks existing Service Broker conversations
USE master;
GO
DECLARE @dbname SYSNAME = 'YourDatabaseName'; -- Specify target database
DECLARE @sql NVARCHAR(MAX);
-- Generate new Service Broker identifier to force reinitialization
SET @sql = 'ALTER DATABASE [' + @dbname + '] SET NEW_BROKER;';
PRINT 'Executing: ' + @sql;
EXEC sp_executesql @sql;
-- Verify the change
SELECT name, service_broker_guid, is_broker_enabled
FROM sys.databases
WHERE name = @dbname;
Clean up orphaned Service Broker objects Removes abandoned Service Broker objects that can cause initialization delays.
-- Run this within the affected database context
USE [YourDatabaseName];
GO
-- Drop unused services (be very careful with this)
DECLARE @service_name SYSNAME;
DECLARE service_cursor CURSOR FOR
SELECT name FROM sys.services
WHERE service_id > 6 -- Skip system services
AND name NOT IN ('YourActiveService1', 'YourActiveService2'); -- Specify active services
OPEN service_cursor;
FETCH NEXT FROM service_cursor INTO @service_name;
WHILE @@FETCH_STATUS = 0
BEGIN
BEGIN TRY
EXEC ('DROP SERVICE [' + @service_name + '];');
PRINT 'Dropped service: ' + @service_name;
END TRY
BEGIN CATCH
PRINT 'Failed to drop service ' + @service_name + ': ' + ERROR_MESSAGE();
END CATCH
FETCH NEXT FROM service_cursor INTO @service_name;
END
CLOSE service_cursor;
DEALLOCATE service_cursor;
AutoDBA generates fix scripts like these automatically, with impact estimates and rollback SQL included.
Prevention
Configure Service Broker only on databases that require message queuing functionality. Many applications enable Service Broker unnecessarily during installation, creating initialization overhead during every database startup or failover.
Monitor Service Broker object counts using automated scripts. Databases with hundreds of queues or services will experience longer initialization times. Implement a cleanup process to remove abandoned Service Broker objects created by development activities or failed deployments.
In Always On Availability Groups, stagger database failovers when possible to avoid simultaneous Service Broker initialization across multiple databases. Consider implementing startup delays for non-critical databases to spread the initialization load.
Set up monitoring for BROKER_INIT wait statistics using DMVs. Alert when wait times exceed 30 seconds or when the wait occurs more than expected based on your maintenance schedule. Most environments should see BROKER_INIT waits only during planned maintenance windows or failover events.
For databases requiring Service Broker, ensure tempdb is properly sized and configured since Service Broker initialization relies heavily on tempdb for temporary metadata operations. Undersized tempdb configurations amplify BROKER_INIT wait duration significantly.
Need hands-on help?
Dealing with persistent broker_init issues across your environment? Samix Technology provides hands-on SQL Server performance consulting with 15+ years of production DBA experience.