Mismatch Between Transactions and Sessions in DMVs sys.dm_tran_session_transactions and sys.dm_tran_database_transactions
0
votes
0
answers
119
views
I've been working with several Dynamic Management Views (DMVs) in SQL Server to monitor transactions, specifically
sys.dm_tran_session_transactions
, sys.dm_tran_database_transactions
, and sys.dm_tran_active_transactions
.
I understand that sys.dm_tran_session_transactions
is used to match sessions and transactions, but I've noticed some inconsistencies. There are instances where I can identify a transaction from sys.dm_tran_database_transactions
or sys.dm_tran_active_transactions
, but I'm unable to find the corresponding session from the sys.dm_tran_session_transactions
DMV.
Why would this occur? Are there certain transactions, perhaps internal ones, that don't have corresponding session IDs? Any insight into this behavior would be greatly appreciated.
Thank you in advance for your help.
## Update
You can use below two queries to easily find a lot of such mismatched session IDs.
SELECT *
FROM sys.dm_tran_active_transactions at
LEFT JOIN sys.dm_tran_session_transactions st
ON st.transaction_id = at.transaction_id
WHERE st.session_id IS NULL;
SELECT *
FROM sys.dm_tran_database_transactions dt
LEFT JOIN sys.dm_tran_session_transactions st
ON st.transaction_id = dt.transaction_id
WHERE st.session_id IS NULL;
Asked by Fajela Tajkiya
(1239 rep)
Oct 18, 2023, 09:57 AM
Last activity: Oct 18, 2023, 01:18 PM
Last activity: Oct 18, 2023, 01:18 PM