Optimized Locking - Transaction ID (TID) Locking internals sample#1453
Optimized Locking - Transaction ID (TID) Locking internals sample#1453segovoni wants to merge 13 commits intomicrosoft:masterfrom
Conversation
uc-msft
left a comment
There was a problem hiding this comment.
Can you modify the script as commented & remove use of DBCC commands?
| COMMIT | ||
| ``` | ||
|
|
||
| Let's explore the content of the dbo.TelemetryPacket table, enriched with the PageId column, which shows the result of the undocumented function sys.fn_PhysLocFormatter. Use this function to correlate the rows returned by the `SELECT` with their physical location on disk. |
There was a problem hiding this comment.
You don't need to use DBCC commands to get the TID information when there is a transaction lock. DBCC commands are not supported in Azure SQL Database also. It is desirable for samples to work on all platforms.
The sys.dm_tran_locks DMV exposes the TID locks as a new resource type = XACT. See the DMV documentation for more details on the exact scenarios.
You can instead do:
BEGIN TRANSACTION
INSERT INTO dbo.TelemetryPacket DEFAULT VALUES;
INSERT INTO dbo.TelemetryPacket DEFAULT VALUES;
INSERT INTO dbo.TelemetryPacket DEFAULT VALUES;
select l.resource_description, l.resource_associated_entity_id, l.resource_lock_partition, l.request_mode, l.request_type, l.request_status, l.request_owner_type
from sys.dm_tran_locks as l
where l.request_session_id = @@SPID
and l.resource_type = 'XACT';
ROLLBACK;
There was a problem hiding this comment.
HI @uc-msft,
thanks for your review. As requested I removed DBCC commands not supported in Azure SQL Database and added the query on the sys.dm_tran_locks DMV to inspect TID value during the transaction.
This PR introduces documentation and setup scripts for understanding Transaction ID (TID) locking internals in SQL Server 2025's Optimized Locking feature.