-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Optimized Locking - Transaction ID (TID) Locking internals sample #1453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Optimized Locking - Transaction ID (TID) Locking internals sample #1453
Conversation
uc-msft
left a comment
There was a problem hiding this 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. |
There was a problem hiding this comment.
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;
This PR introduces documentation and setup scripts for understanding Transaction ID (TID) locking internals in SQL Server 2025's Optimized Locking feature.