提问人:Liero 提问时间:9/28/2023 更新时间:9/28/2023 访问量:31
tempdb 中的挂起事务是什么意思?
What hanging transaction in tempdb mean?
问:
我正在尝试解决在生产中查询特定表时导致超时的原因。
我怀疑有一些未提交的事务,所以我运行了以下查询:
SELECT trans.session_id AS [SESSION ID]
,ESes.host_name AS [HOST NAME]
,login_name AS [Login NAME]
,trans.transaction_id AS [TRANSACTION ID]
,tas.name AS [TRANSACTION NAME]
,tas.transaction_begin_time AS [TRANSACTION BEGIN TIME]
,tds.database_id AS [DATABASE ID]
,DBs.name AS [DATABASE NAME]
FROM sys.dm_tran_active_transactions tas
JOIN sys.dm_tran_session_transactions trans ON (trans.transaction_id = tas.transaction_id)
LEFT OUTER JOIN sys.dm_tran_database_transactions tds ON (tas.transaction_id = tds.transaction_id)
LEFT OUTER JOIN sys.databases AS DBs ON tds.database_id = DBs.database_id
LEFT OUTER JOIN sys.dm_exec_sessions AS ESes ON trans.session_id = ESes.session_id
WHERE ESes.session_id IS NOT NULL
它返回了两行相同的行,一行是数据库名称,另一行是我的应用程序的数据库:[Session ID]
tempdb
SESSION ID, Login Name, ... TRANSACTION BEGIN TIME, DATABASE NAME,
218, MyAppSQLUser, 15 minutes ago, tempdb
218, MyAppSQLUser, ..., MyDatabase
KILL 218
解决了超时问题
tempdb 行是否指示某些内容?为什么会在那里举办活动
下一步是什么?我将来如何追踪交易的来源,以便我找出导致它的原因?
答: 暂无答案
评论
using
finally
XACT_ABORT ON