V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
idragonet

请教: MSSQL 如何确定死锁根源 session_id?

  •  
  •   idragonet · Aug 30, 2023 · 2554 views
    This topic created in 984 days ago, the information mentioned may be changed or developed.
    • 背景:MSSQL 2016 每几天死锁一次。
    SELECT sqltext.text,
           req.session_id,
           req.status,
           req.command,
           req.cpu_time,
           req.total_elapsed_time,
           req.blocking_session_id
    FROM sys.dm_exec_requests req (NOLOCK)
        CROSS APPLY sys.dm_exec_sql_text(req.sql_handle) AS sqltext
    

    执行上面 SQL ,通过 blocking_session_id 发现阻塞 session 最终矛头都指向是 session 134 。 但是 session 134 的状态是 suspended ( session 134 的 blocking_session_id=0 ),正常不是应该状态是 running 才可能是阻塞根源的 session 吗?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   841 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 20:51 · PVG 04:51 · LAX 13:51 · JFK 16:51
    ♥ Do have faith in what you're doing.