Optimized Locking - Transaction ID (TID) Locking internals sample#1453
Open
segovoni wants to merge 11 commits intomicrosoft:masterfrom
Open
Optimized Locking - Transaction ID (TID) Locking internals sample#1453segovoni wants to merge 11 commits intomicrosoft:masterfrom
segovoni wants to merge 11 commits intomicrosoft:masterfrom
Conversation
uc-msft
requested changes
Feb 2, 2026
Contributor
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. |
Contributor
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;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces documentation and setup scripts for understanding Transaction ID (TID) locking internals in SQL Server 2025's Optimized Locking feature.