(Republishing, or using this info in a commercial product/website, is prohibited without permission. All other uses are permitted. If in doubt, please ask.)

SLEEP_TASK

(Back to main page…)

Description:

This wait type is a general wait indicating that a thread is waiting for some event to occur, including background task scheduling, during hash spills to tempdb, and for some query plan exchange operators where the wait isn’t tracked by either CXPACKET or EXECSYNC waits.

(Books Online description: “Occurs when a task sleeps while waiting for a generic event to occur.”)

Questions/comments on this wait type? Click here to send Paul an email, especially if you have any information to add to this topic.

Added in SQL Server version:

Pre-2005/2005

Removed in SQL Server version:

N/A

Extended Events wait_type value:

The map_key value in sys.dm_xe_map_values is 105 in 2008 and 2008 R2, and 109 in 2012 and 2014 RTM. After 2014 RTM, you must check the DMV to get the latest value as some map_key values have changed in later builds.

Other information:

Although this is generally a benign wait type that is usually filtered out of the results from sys.dm_os_wait_stats, you may see this wait type while looking at sys.dm_os_waiting_tasks output (using my script). If that’s the case, look for hash spills happening and troubleshoot those.

This wait type is one that I usually filter out as a benign wait when doing wait statistics analysis.

Known occurrences in SQL Server (list number matches call stack list):

  1. Waiting for an exchange event during a scan
  2. Waiting for an exchange event during a stream aggregate
  3. Waiting to determine whether to put the ghost cleanup task to sleep or to carry on using the processor if it’s idle

And many other similar call stacks.

Abbreviated call stacks (list number matches known occurrences list):

  1. SOS_Task::PostWait+9e
    SOS_Task::Sleep+149
    CXPipe::GetRow+277
    CXPipeMerge::GetRow+c0
    CQScanExchangeNew::GetRowHelper+19b
    CQScanTopNew::GetRow+171
    CQueryScan::GetRow+81
    CXStmtQuery::ErsqExecuteQuery+36d
    CXStmtSelect::XretExecute+2e7
    CMsqlExecContext::ExecuteStmts<1,1>+427
    CMsqlExecContext::FExecute+a43
    CSQLSource::Execute+86c
    process_request+a57
    process_commands+4a3
    SOS_Task::Param::Execute+21e
    SOS_Scheduler::RunTask+ab
  2. SOS_Task::PostWait+9e
    SOS_Task::Sleep+149
    CXPipe::GetRow+277
    CXPipeMerge::ReleaseRow+91
    CXPipeMerge::GetRow+228
    CQScanExchangeNew::GetRowHelper+19b
    CQScanStreamAggregateNew::GetRowHelper+1fc
    CQScanUpdateNew::GetRow+76
    CQScanXProducerNew::GetRowHelper+366
    CQScanXProducerNew::GetRow+15
    FnProducerOpen+57
    FnProducerThread+8c3
    SubprocEntrypoint+a7f
    SOS_Task::Param::Execute+21e
    SOS_Scheduler::RunTask+ab
  3. SOS_Task::PostWait+9e
    SOS_Task::Sleep+149
    CanSuspendGhostCleanup+d8
    GhostRecordCleanupTask+1c1
    CGhostCleanupTask::ProcessTskPkt+9
    TaskReqPktTimer::ExecuteTask+63
    OnDemandTaskContext::ProcessTskPkt+3e2
    SystemTaskEntryPoint+426
    OnDemandTaskContext::FuncEntryPoint+25
    SOS_Task::Param::Execute+21e
    SOS_Scheduler::RunTask+ab