Why This Error Happens
Error 5859 is raised when SQL Server detects that the server has more than 64 logical processors (i.e., Windows has split the processors into multiple processor groups), but the instance is still configured to use the legacy bitmask-based affinity settings (affinity mask / affinity64 mask via sp_configure). Those masks are only 64 bits wide, so they physically cannot address processors beyond the 64th logical CPU. SQL Server blocks any attempt to reconfigure or start with this mismatch and requires you to first switch the server to the newer ALTER SERVER CONFIGURATION ... SET PROCESS AFFINITY syntax, which is processor-group aware. This is strictly a CPU affinity/processor-group configuration issue — it is unrelated to permissions, networking, or database corruption.
Step-by-Step Resolution Guide
Step 1: Confirm the server’s logical processor count and processor group layout
- From an elevated PowerShell prompt, run:
Get-CimInstance Win32_ComputerSystem | Select-Object NumberOfLogicalProcessors, NumberOfProcessors - Confirm how Windows has grouped the processors by running:
Get-CimInstance Win32_Processor | Select-Object DeviceID, NumberOfLogicalProcessors - In SQL Server, connect via SSMS or
sqlcmdand run:
SELECT cpu_count, scheduler_count, softnuma_configuration_desc
FROM sys.dm_os_sys_info;
- Also run the following to see how SQL Server has mapped schedulers to processor groups and NUMA nodes:
SELECT scheduler_id, cpu_id, parent_node_id, status
FROM sys.dm_os_schedulers
WHERE status = 'VISIBLE ONLINE';
- Record the total logical processor count and whether it exceeds 64 (indicating multiple Windows processor groups).
Step 2: Review the current affinity configuration in SQL Server
- Connect to the instance in SSMS or
sqlcmd. - Run the following to see the legacy mask-based settings and their current/pending state:
SELECT name, value, value_in_use, minimum, maximum
FROM sys.configurations
WHERE name IN ('affinity mask', 'affinity64 mask', 'affinity I/O mask', 'affinity64 I/O mask');
- Also check whether the instance is already in CPU-affinity-group mode by running:
SELECT * FROM sys.dm_os_node_memory_allocators;
or, more directly, review the current affinity map in the error log (see Step 5) for a line beginning with “Server process ID is…” followed by “SQL Server affinity…” entries at startup.
Step 3: Back up the current configuration values
- Export the result set from Step 2 to a text file for reference before making any changes, for example by running
sqlcmdwith output redirection:
sqlcmd -S localhost -E -Q "SELECT name, value, value_in_use FROM sys.configurations WHERE name LIKE 'affinity%'" -o "C:\SQLConfigBackups\affinity_backup_before.txt" - Confirm the file was created and review its contents before proceeding.
Step 4: Update the affinity settings to reference only valid processors
- Because the legacy
affinity mask/affinity64 maskoptions cannot support more than 64 processors, you must first reset the instance to automatic, processor-group-aware affinity management by running:
ALTER SERVER CONFIGURATION SET PROCESS AFFINITY CPU = AUTO;
- This clears the incompatible bitmask settings and lets SQL Server automatically schedule across all available processor groups.
- If you need SQL Server to use only specific processors (rather than all of them), specify the exact CPU IDs or ranges instead of
AUTO, for example:
ALTER SERVER CONFIGURATION SET PROCESS AFFINITY CPU = (0 TO 63, 64 TO 71);
List the CPU IDs exactly as reported in sys.dm_os_schedulers from Step 1 so the ranges align with the real processor group boundaries.
- Do not re-enable
affinity maskoraffinity64 maskviasp_configureon a server with more than 64 logical processors; these legacy options are only valid for single-group servers with 64 or fewer logical CPUs.
Step 5: Restart the SQL Server service and check the error log
- Restart the Database Engine service using PowerShell (replace
MSSQLSERVERwith your named instance, e.g.MSSQL$INSTANCENAME, if applicable):
Restart-Service -Name 'MSSQLSERVER' -Force - Review the current SQL Server error log, located by default at:
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG - You can also query the log directly from within SQL Server instead of opening the file:
EXEC sp_readerrorlog 0, 1, N'affinity';
- Confirm there are no further references to Error 5859 or to affinity mask/processor-group mismatches during startup.
Alternative or Verification Steps
- Verify the fix: Re-run the query from Step 2 and confirm `