MAX worker thread in SQL server 2012/14/16 I was just browsing the system health extended event to come across an event with diagnostic result for query processing showing status for worker threads:


Why max worker threads showing 2994 when I have 80 logical processors which as per msdn calculation here 512 + ((logical CPU's - 4) * 16) does not looks correct. However per the latest link here makes sense for logical processors greater than 64 where calculation for 16 changes to 32. But that link says starting SQL 2017, however the number 2994 I am getting is for SQL2012, 14 16 where no of logical processors is 80. Am I missing something here?


max worker setting within sp_configure is set to '0'


Coming back to that system health event status shows WARNING for below no:



  maxWorkers="2944" workersCreated="456" workersIdle="314"
  tasksCompletedWithinInterval="1021881" pendingTasks="1"


Should I be checking something else or can this be ignored?
why max worker threads showing 2994 when i have 80 logical processors […]
  


It seems there is a documentation error when the item was copied over from MSDN to Docs. What you see in Dorr's post is correct and is applicable back to 2012 SP4 + latest CUs. I'll make the required documentation changes. The documentation has been updated.


  
  Coming back to that system health event status shows WARNING for below no […]
  


The reason you have a warning is because you have pendingTasks="1". This could indicate an issue with a scheduler and should be investigated.


  I see pending task count varying sometimes 2, 4 , 8 or even higher.


In the same Docs article that you linked, there is a query that can be used to track tasks and their status. It'd be interesting to see if it's only tasks on a specific scheduler, only login tasks, etc.

SELECT  s.session_id, r.command, r.status,  
   r.wait_type, r.scheduler_id, w.worker_address,  
   w.is_preemptive, w.state, t.task_state,  
   t.session_id, t.exec_context_id, t.request_id  
FROM sys.dm_exec_sessions AS s  
INNER JOIN sys.dm_exec_requests AS r  
   ON s.session_id = r.session_id  
INNER JOIN sys.dm_os_tasks AS t  
   ON r.task_address = t.task_address  
INNER JOIN sys.dm_os_workers AS w  
   ON t.worker_address = w.worker_address  
WHERE t.task_state = N'PENDING'