Quick Answer
BROKER_REGISTERALLENDPOINTS occurs when SQL Server initializes Service Broker endpoints during instance startup or when creating new Service Broker routes. This wait is normal during startup but persistent occurrences indicate Service Broker connectivity issues or endpoint configuration problems.
Root Cause Analysis
Service Broker uses TCP endpoints for inter-instance communication, and BROKER_REGISTERALLENDPOINTS fires when the Service Broker activation manager attempts to register all configured endpoints with the network layer. During SQL Server startup, the Service Broker subsystem enumerates all routes in sys.routes and attempts to establish endpoint registrations for remote service communication.
The wait occurs in the SQLOS scheduler when Service Broker threads compete for endpoint registration locks within the Service Broker transport layer. Each endpoint registration requires acquiring exclusive access to the endpoint configuration metadata and validating network connectivity parameters including port availability and certificate authentication settings.
In SQL Server 2016 and earlier, endpoint registration was synchronous and could cause noticeable startup delays. SQL Server 2017 introduced asynchronous endpoint initialization, reducing startup impact but potentially extending the window where these waits appear. SQL Server 2019 added enhanced endpoint pooling, which reduced the frequency of re-registration events but made persistent waits more indicative of actual connectivity problems.
The wait specifically manifests when the Service Broker transport manager calls into the network abstraction layer to bind TCP sockets. Network-related delays, DNS resolution timeouts, or certificate validation failures extend these waits beyond the typical microsecond range into problematic territory.
AutoDBA checks Service Broker endpoint configuration, route validation, and connection monitoring across your entire SQL Server instance in 60 seconds. Download the free diagnostic script and see what else needs attention.
Diagnostic Queries
-- Check current Service Broker endpoint status and configuration
SELECT
e.name,
e.protocol_desc,
e.type_desc,
e.state_desc,
te.port,
te.is_admin_endpoint,
te.certificate_id
FROM sys.endpoints e
JOIN sys.tcp_endpoints te ON e.endpoint_id = te.endpoint_id
WHERE e.type_desc = 'SERVICE_BROKER';
-- Identify problematic Service Broker routes and their endpoints
SELECT
r.name AS route_name,
r.remote_service_name,
r.broker_instance,
r.address,
r.mirror_address
FROM sys.routes r
WHERE r.address IS NOT NULL;
-- Check Service Broker connections separately
SELECT
connection_id,
state_desc AS connection_state,
connect_time,
login_time,
peer_certificate_id
FROM sys.dm_broker_connections;
-- Monitor current Service Broker 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 LIKE 'BROKER%'
ORDER BY wait_time_ms DESC;
-- Check Service Broker queue monitors and transmission queue status
SELECT
DB_NAME(database_id) AS database_name,
queue_name,
state,
last_activated_time,
last_empty_rowset_time,
tasks_waiting
FROM sys.dm_broker_queue_monitors;
SELECT
DB_NAME(st.database_id) AS database_name,
st.to_service_name,
COUNT(*) AS message_count,
MAX(st.enqueue_time) AS last_enqueue_time
FROM sys.transmission_queue st
GROUP BY st.database_id, st.to_service_name;
-- Check SQL Server error log for Service Broker endpoint issues
EXEC xp_readerrorlog 0, 1, N'Service Broker', NULL, NULL, NULL, N'DESC';
Fix Scripts
Restart Service Broker endpoints to clear stuck registrations
-- Disable and re-enable Service Broker endpoints to force re-registration
-- WARNING: This will drop active Service Broker connections
DECLARE @endpoint_name SYSNAME;
DECLARE endpoint_cursor CURSOR FOR
SELECT e.name
FROM sys.endpoints e
WHERE e.type_desc = 'SERVICE_BROKER' AND e.state_desc = 'STARTED';
OPEN endpoint_cursor;
FETCH NEXT FROM endpoint_cursor INTO @endpoint_name;
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC('ALTER ENDPOINT [' + @endpoint_name + '] STATE = STOPPED');
WAITFOR DELAY '00:00:02'; -- Brief pause
EXEC('ALTER ENDPOINT [' + @endpoint_name + '] STATE = STARTED');
FETCH NEXT FROM endpoint_cursor INTO @endpoint_name;
END;
CLOSE endpoint_cursor;
DEALLOCATE endpoint_cursor;
Clear problematic Service Broker routes
-- Identify routes with invalid addresses that cause endpoint registration failures
SELECT name, remote_service_name, address
FROM sys.routes
WHERE address IS NOT NULL
AND address NOT LIKE 'TCP://%'
AND name != 'AutoCreatedLocal';
-- Drop invalid routes individually (replace with your route names)
-- Test in development first as this affects Service Broker message routing
-- DROP ROUTE [YourInvalidRouteName];
-- Recreate routes with proper TCP format
-- Replace with actual target server addresses
/*
CREATE ROUTE [YourRouteName]
WITH SERVICE_NAME = 'YourServiceName',
ADDRESS = 'TCP://targetserver.domain.com:4022',
MIRROR_ADDRESS = 'TCP://targetmirror.domain.com:4022';
*/
Reset Service Broker activation procedures
-- Disable and re-enable queue activation to resolve stuck endpoint registrations
-- This forces Service Broker to re-evaluate route endpoints
DECLARE @sql NVARCHAR(MAX) = '';
SELECT @sql = @sql +
'ALTER QUEUE [' + SCHEMA_NAME(schema_id) + '].[' + name + '] WITH STATUS = OFF;' + CHAR(13) +
'ALTER QUEUE [' + SCHEMA_NAME(schema_id) + '].[' + name + '] WITH STATUS = ON;' + CHAR(13)
FROM sys.service_queues
WHERE is_activation_enabled = 1;
PRINT @sql; -- Review before executing
-- EXEC sp_executesql @sql; -- Uncomment to execute
Force Service Broker endpoint cleanup
-- Clear procedure cache to resolve persistent endpoint issues
-- WARNING: This causes recompilation of all queries
DBCC FREEPROCCACHE;
-- Disable and re-enable Service Broker on the specific affected database
-- WARNING: This ends all active conversations in the database
-- ALTER DATABASE [YourDatabaseName] SET DISABLE_BROKER;
-- ALTER DATABASE [YourDatabaseName] SET ENABLE_BROKER;
AutoDBA generates fix scripts like these automatically, with impact estimates and rollback SQL included.
Prevention
Configure Service Broker endpoints with specific IP addresses rather than wildcards to prevent DNS resolution delays during endpoint registration. Set explicit port numbers and avoid dynamic port allocation which requires additional endpoint enumeration cycles.
Implement Service Broker route validation during deployment by testing TCP connectivity to target endpoints before creating routes. Use PowerShell Test-NetConnection or telnet to verify port accessibility from the SQL Server service account context.
Monitor sys.dm_broker_connections regularly to identify connection failures before they manifest as persistent BROKER_REGISTERALLENDPOINTS waits. Establish alerts for connection_state values of 'ERROR' or repeated 'CONNECTING' states.
Configure appropriate certificate-based authentication for Service Broker endpoints to eliminate certificate validation delays. Pre-install certificates in the master database certificate store and reference them explicitly in endpoint definitions rather than relying on automatic certificate generation.
Separate Service Broker traffic to dedicated network interfaces when possible, particularly in clustered environments where endpoint registration competes with cluster heartbeat traffic. This reduces network-layer contention during endpoint initialization phases.
Need hands-on help?
Dealing with persistent broker_registerallendpoints issues across your environment? Samix Technology provides hands-on SQL Server performance consulting with 15+ years of production DBA experience.