Skip to content

Conversation

@segovoni
Copy link
Contributor

@segovoni segovoni commented Dec 8, 2025

This PR introduces documentation and setup scripts for understanding Transaction ID (TID) locking internals in SQL Server 2025's Optimized Locking feature.

Copy link
Contributor

@uc-msft uc-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants