Troubleshooting Guide: SQL Server Error 5855 – Affinity Setting Not Changed
Why This Error Happens
Error 5855 occurs when SQL Server 2025 cannot apply CPU affinity mask changes because the operation requires memory or system handles that are not currently available. This is typically triggered by low virtual memory, insufficient non-paged pool resources, or another process (including SQL Server’s own worker threads) holding a lock on the affinity configuration during a high-load state. It can also surface when the configured affinity mask conflicts with the number of CPUs actually exposed to the Windows Server 2025 / Windows 11 instance, such as after a VM resource reallocation.
Step-by-Step Resolution Guide
Step 1: Verify Current System Resource Availability
- Open Task Manager or Performance Monitor (
perfmon.exe) and check Available MBytes and Committed Bytes under the Memory category. - Run
DBCC MEMORYSTATUSin SQL Server Management Studio (SSMS) to inspect internal memory pressure. - Check Windows Event Viewer under Windows Logs > System for related resource-exhaustion warnings (e.g., Event ID 2019 or 333).
Step 2: Reconcile CPU Count and Affinity Mask Configuration
- Confirm the number of logical processors visible to the OS via
msinfo32.exeor by runningSELECT cpu_count FROM sys.dm_os_sys_info;in SSMS. - Compare this against the configured affinity mask using
sp_configure 'affinity mask'andsp_configure 'affinity64 mask'. - If the VM or host recently had vCPUs added/removed, update the affinity mask using
ALTER SERVER CONFIGURATION SET PROCESS AFFINITY CPU = AUTO;to let SQL Server auto-reconcile.
Step 3: Free Up System Resources Before Retrying
- Close unnecessary background services or applications consuming non-paged pool memory.
- Increase the page file size temporarily: Navigate to System Properties > Advanced > Performance Settings > Advanced > Virtual Memory and set a custom size (e.g., 1.5x physical RAM).
- Restart the SQL Server service (
net stop MSSQLSERVERthennet start MSSQLSERVER) during a maintenance window to clear any stuck resource locks.
Step 4: Reapply the Affinity Setting
- Re-run the affinity configuration command, for example:
ALTER SERVER CONFIGURATION SET PROCESS AFFINITY CPU = 0, 1, 2, 3; - Execute
RECONFIGURE;immediately after to commit the change. - Monitor the SQL Server Error Log (via SSMS or
%ProgramFiles%\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for confirmation or repeated 5855 errors.
Alternative or Verification Steps
- Verify the fix by querying
SELECT * FROM sys.dm_os_nodes;to confirm each CPU node reflects the intended affinity mapping without errors. - If the issue persists, use Resource Governor to cap workload resource consumption, or escalate to the host/hypervisor admin to confirm no CPU hot-add/remove operations are conflicting with SQL Server’s cached processor topology.