LATCH_SH

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

(Back to main page…)

Description:

This wait type occurs when a thread is waiting for access to a non-page data structure so that it can read the data structure. The thread cannot get access to the data structure because another thread has it latched in exclusive mode. For a full description of non-page latches and investigating them, see the LATCH_EX wait type.

(Books Online description: “Occurs when waiting for a SH (share) latch. This does not include buffer latches or transaction mark latches. A listing of LATCH_* waits is available in sys.dm_os_latch_stats. Note that sys.dm_os_latch_stats groups LATCH_NL, LATCH_SH, LATCH_UP, LATCH_EX, and LATCH_DT waits together.”)

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 34 in all versions through 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:

For a full description of non-page latches and investigating them, see the LATCH_EX wait type.

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

  1. Waiting for the FGCB_ADD_REMOVE latch to determine which filegroup file to allocate from (in this case, while copying a LOB value)
  2. Waiting for the TRACE_CONTROLLER latch to read the list of active Profiler traces (in this case, while periodically flushing them)

And many, many more stacks around the set of non-page latches.

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

  1. SOS_Task::PostWait+90
    EventInternal::Wait+1f9
    LatchBase::Suspend+633
    LatchBase::AcquireInternal+415
    FGCB::GetAllocFCB+7a
    AllocationReq::AllocatePages+175c
    AllocationReq::Allocate+f3
    CompactSpaceAllocator::AllocateAndFixPage+338
    CompactSpaceAllocator::AllocateAndFixPageInternal+ae
    CompactSpaceAllocator::FindSpaceAndFixPage+134
    BlobBase::AllocDataNode+26f
    Blob::InsertNonFull+34a
    Blob::InsertWholePage+177
    Blob::Insert+236
    BlobManager::ReplaceAtWithILB+5d0
    LockBytesSS::ReplaceAtWithILB+17
    CMainIlb::ReplaceAtWithILB+90
    CBlobHandleFactories::CopyIlbRaiseError+70
    CBlobHandleHelper::CopyBlobHandleIntoTempOrInlined+1f2
    CBlobHandleManagerCommon::PxvarPreprocessInternal+126
    CValRowNoHrow::SetDataX+28
  2. SOS_Task::PostWait+90
    EventInternal::Wait+1f9
    LatchBase::Suspend+633
    LatchBase::AcquireInternal+415
    CTraceController::IncrementalFlush+7b
    CTraceManagementTask::Invoke+83
    CTraceBatchTask::Task+259
    SOS_Task::Param::Execute+21e
    SOS_Scheduler::RunTask+a8/li>