Why does this RX-X lock not appear in Extended Events?Is there a more helpful way to detect lock acquire/release stats in SQL Profiler?Synchronize Queries Retrieving Sessions And Locks From DMVsHold exclusive lock on a whole DBCan I rely on reading SQL Server Identity values in order?What interval does SQL Server Profiler's “duration” refer to?Extended Events filteringExtended event for lock count does not show locksWhy adding FOREIGN KEY constraint does not lock the tableSQL Server Exclusive(X) lock not consistently blocking Shared(S) lock on a resourceWhy does an UPDATE to a full-text-indexed column lock the full text index?

Can a black hole formation be stopped or interrupted

(3 of 11: Akari) What is Pyramid Cult's Favorite Car?

How does one get an animal off of the Altar surreptitiously?

What is this 4 sharp symbol and what does it mean?

How to store my pliers and wire cutters on my desk?

Is there a way to know the composition of a Team GO Rocket before going into the fight?

What is more environmentally friendly? An A320 or a car?

What would the United Kingdom's "optimal" Brexit deal look like?

reconstruction filter - How does it actually work?

Why did I lose on time with 3 pawns vs Knight. Shouldn't it be a draw?

Why does this RX-X lock not appear in Extended Events?

Should I bike or drive to work? (6.8 mi)

What do you call a flexible diving platform?

Why do they sell Cat 5 Ethernet splitters if you can’t split the signal?

Move the outer key inward in an association

Summoning A Technology Based Demon

Irreducible factors of primitive permutation group representation

Does Wolfram Mathworld make a mistake describing a discrete probability distribution with a probability density function?

Struggling with cyclical dependancies in unit tests

Do the books ever say oliphaunts aren’t elephants?

Assuring luggage isn't lost with short layover

Will this creature from Curse of Strahd reappear after being banished?

What do I do with a party that is much stronger than their level?

What is the most efficient way to write 'for' loops in Matlab?



Why does this RX-X lock not appear in Extended Events?


Is there a more helpful way to detect lock acquire/release stats in SQL Profiler?Synchronize Queries Retrieving Sessions And Locks From DMVsHold exclusive lock on a whole DBCan I rely on reading SQL Server Identity values in order?What interval does SQL Server Profiler's “duration” refer to?Extended Events filteringExtended event for lock count does not show locksWhy adding FOREIGN KEY constraint does not lock the tableSQL Server Exclusive(X) lock not consistently blocking Shared(S) lock on a resourceWhy does an UPDATE to a full-text-indexed column lock the full text index?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








9















The Problem



I have a pair of queries that, under serializable isolation, cause an RX-X lock. However, when I use Extended Events to watch lock acquisition, the RX-X lock acquisition never appears, it is only released. Where does it come from?



The Repro



Here's my table:



CREATE TABLE dbo.LockTest (
ID int identity,
Junk char(4)
)

CREATE CLUSTERED INDEX CX_LockTest --not unique!
ON dbo.LockTest(ID)

--preload some rows
INSERT dbo.LockTest
VALUES ('data'),('data'),('data')


Here's my problem batch:



SET TRANSACTION ISOLATION LEVEL SERIALIZABLE

BEGIN TRAN

INSERT dbo.LockTest
VALUES ('bleh')

SELECT *
FROM dbo.LockTest
WHERE ID = SCOPE_IDENTITY()

--ROLLBACK


I check locks held by this session, and see RX-X:



SELECT resource_type, request_mode, request_status, resource_description
FROM sys.dm_tran_locks
WHERE request_session_id = 72 --change SPID!


dm_tran_locks



But I also have an Extended Event on lock_acquired and lock_released. I filter it on the appropriate associated_object_id...there's no RX-X.



Extended Event output



After executing the rollback, I see RX-X (LAST_MODE) released, even though it was never acquired.



LAST_MODE



What I've Tried



  • I looked at all locks in Extended Events - no filtering. No RX-X locks acquired.


  • I also tried Profiler: same results (except of course it gets the name right...no "LAST_MODE").


  • I ran the XE for lock escalations - it's not there.


  • There's no XE specifically for conversions, but I was able to confirm that at least the U to X lock conversion is captured by lock_acquired


Also of note is the RI-N that gets acquired but never released. My current hypothesis is that the RX-X is a conversion lock, as described here. There are overlapping key-range locks in my batch that look like they should qualify for conversion, but the RX-X lock isn't in the conversion table.



Where is this lock coming from, and why isn't it picked up by Extended Events?










share|improve this question






























    9















    The Problem



    I have a pair of queries that, under serializable isolation, cause an RX-X lock. However, when I use Extended Events to watch lock acquisition, the RX-X lock acquisition never appears, it is only released. Where does it come from?



    The Repro



    Here's my table:



    CREATE TABLE dbo.LockTest (
    ID int identity,
    Junk char(4)
    )

    CREATE CLUSTERED INDEX CX_LockTest --not unique!
    ON dbo.LockTest(ID)

    --preload some rows
    INSERT dbo.LockTest
    VALUES ('data'),('data'),('data')


    Here's my problem batch:



    SET TRANSACTION ISOLATION LEVEL SERIALIZABLE

    BEGIN TRAN

    INSERT dbo.LockTest
    VALUES ('bleh')

    SELECT *
    FROM dbo.LockTest
    WHERE ID = SCOPE_IDENTITY()

    --ROLLBACK


    I check locks held by this session, and see RX-X:



    SELECT resource_type, request_mode, request_status, resource_description
    FROM sys.dm_tran_locks
    WHERE request_session_id = 72 --change SPID!


    dm_tran_locks



    But I also have an Extended Event on lock_acquired and lock_released. I filter it on the appropriate associated_object_id...there's no RX-X.



    Extended Event output



    After executing the rollback, I see RX-X (LAST_MODE) released, even though it was never acquired.



    LAST_MODE



    What I've Tried



    • I looked at all locks in Extended Events - no filtering. No RX-X locks acquired.


    • I also tried Profiler: same results (except of course it gets the name right...no "LAST_MODE").


    • I ran the XE for lock escalations - it's not there.


    • There's no XE specifically for conversions, but I was able to confirm that at least the U to X lock conversion is captured by lock_acquired


    Also of note is the RI-N that gets acquired but never released. My current hypothesis is that the RX-X is a conversion lock, as described here. There are overlapping key-range locks in my batch that look like they should qualify for conversion, but the RX-X lock isn't in the conversion table.



    Where is this lock coming from, and why isn't it picked up by Extended Events?










    share|improve this question


























      9












      9








      9


      1






      The Problem



      I have a pair of queries that, under serializable isolation, cause an RX-X lock. However, when I use Extended Events to watch lock acquisition, the RX-X lock acquisition never appears, it is only released. Where does it come from?



      The Repro



      Here's my table:



      CREATE TABLE dbo.LockTest (
      ID int identity,
      Junk char(4)
      )

      CREATE CLUSTERED INDEX CX_LockTest --not unique!
      ON dbo.LockTest(ID)

      --preload some rows
      INSERT dbo.LockTest
      VALUES ('data'),('data'),('data')


      Here's my problem batch:



      SET TRANSACTION ISOLATION LEVEL SERIALIZABLE

      BEGIN TRAN

      INSERT dbo.LockTest
      VALUES ('bleh')

      SELECT *
      FROM dbo.LockTest
      WHERE ID = SCOPE_IDENTITY()

      --ROLLBACK


      I check locks held by this session, and see RX-X:



      SELECT resource_type, request_mode, request_status, resource_description
      FROM sys.dm_tran_locks
      WHERE request_session_id = 72 --change SPID!


      dm_tran_locks



      But I also have an Extended Event on lock_acquired and lock_released. I filter it on the appropriate associated_object_id...there's no RX-X.



      Extended Event output



      After executing the rollback, I see RX-X (LAST_MODE) released, even though it was never acquired.



      LAST_MODE



      What I've Tried



      • I looked at all locks in Extended Events - no filtering. No RX-X locks acquired.


      • I also tried Profiler: same results (except of course it gets the name right...no "LAST_MODE").


      • I ran the XE for lock escalations - it's not there.


      • There's no XE specifically for conversions, but I was able to confirm that at least the U to X lock conversion is captured by lock_acquired


      Also of note is the RI-N that gets acquired but never released. My current hypothesis is that the RX-X is a conversion lock, as described here. There are overlapping key-range locks in my batch that look like they should qualify for conversion, but the RX-X lock isn't in the conversion table.



      Where is this lock coming from, and why isn't it picked up by Extended Events?










      share|improve this question














      The Problem



      I have a pair of queries that, under serializable isolation, cause an RX-X lock. However, when I use Extended Events to watch lock acquisition, the RX-X lock acquisition never appears, it is only released. Where does it come from?



      The Repro



      Here's my table:



      CREATE TABLE dbo.LockTest (
      ID int identity,
      Junk char(4)
      )

      CREATE CLUSTERED INDEX CX_LockTest --not unique!
      ON dbo.LockTest(ID)

      --preload some rows
      INSERT dbo.LockTest
      VALUES ('data'),('data'),('data')


      Here's my problem batch:



      SET TRANSACTION ISOLATION LEVEL SERIALIZABLE

      BEGIN TRAN

      INSERT dbo.LockTest
      VALUES ('bleh')

      SELECT *
      FROM dbo.LockTest
      WHERE ID = SCOPE_IDENTITY()

      --ROLLBACK


      I check locks held by this session, and see RX-X:



      SELECT resource_type, request_mode, request_status, resource_description
      FROM sys.dm_tran_locks
      WHERE request_session_id = 72 --change SPID!


      dm_tran_locks



      But I also have an Extended Event on lock_acquired and lock_released. I filter it on the appropriate associated_object_id...there's no RX-X.



      Extended Event output



      After executing the rollback, I see RX-X (LAST_MODE) released, even though it was never acquired.



      LAST_MODE



      What I've Tried



      • I looked at all locks in Extended Events - no filtering. No RX-X locks acquired.


      • I also tried Profiler: same results (except of course it gets the name right...no "LAST_MODE").


      • I ran the XE for lock escalations - it's not there.


      • There's no XE specifically for conversions, but I was able to confirm that at least the U to X lock conversion is captured by lock_acquired


      Also of note is the RI-N that gets acquired but never released. My current hypothesis is that the RX-X is a conversion lock, as described here. There are overlapping key-range locks in my batch that look like they should qualify for conversion, but the RX-X lock isn't in the conversion table.



      Where is this lock coming from, and why isn't it picked up by Extended Events?







      sql-server locking sql-server-2017






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 11 hours ago









      ForrestForrest

      3,2141 gold badge9 silver badges26 bronze badges




      3,2141 gold badge9 silver badges26 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          3














          The single row insert acquires an X (exclusive) lock on the new row.



          The SELECT attempts to acquire a range-shared, key shared (RangeS-S) lock.



          This request is reported by the lock_acquired Extended Event as mode = RS_S.



          It is reported by the Profiler event class Lock:Acquired as mode 13 (LCK_M_RS_S).



          The requested mode is combined with the existing exclusive lock mode in Lock::CalculateGrantMode in sqlmin.dll. There is no combined mode of range-shared, key exclusive (RangeS-X) so the outcome of the calculation is range-exclusive, key exclusive (RangeX-X), which happens to be mode 15.



          The grant mode calculation is performed just before the extended event is generated by lck_ProduceExtendedEvent<XeSqlPkg::lock_acquired>. Nevertheless, both Profiler and Extended Events log the requested RangeS-S mode, not the resulting lock mode RangeX-X. This is counter to the limited documentation, which says:




          Mode | int | Resulting mode after the lock was acquired.




          The mode column of the extended event has no documentation at all, and the description in the meta data is blank. Perhaps Microsoft themselves weren't even sure of the behaviour.



          The mysterious LAST_MODE is something Erik Darling has remarked on before.



          I have often thought it would be more useful if lock events reported both the requested and resulting modes, but that is not what we have. The current arrangement makes it pretty much impossible to track and match up lock acquisition and release.



          There might be a good reason for reporting locks this way. If it doesn't meet your needs, you could open a support case with Microsoft.






          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "182"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f244054%2fwhy-does-this-rx-x-lock-not-appear-in-extended-events%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            The single row insert acquires an X (exclusive) lock on the new row.



            The SELECT attempts to acquire a range-shared, key shared (RangeS-S) lock.



            This request is reported by the lock_acquired Extended Event as mode = RS_S.



            It is reported by the Profiler event class Lock:Acquired as mode 13 (LCK_M_RS_S).



            The requested mode is combined with the existing exclusive lock mode in Lock::CalculateGrantMode in sqlmin.dll. There is no combined mode of range-shared, key exclusive (RangeS-X) so the outcome of the calculation is range-exclusive, key exclusive (RangeX-X), which happens to be mode 15.



            The grant mode calculation is performed just before the extended event is generated by lck_ProduceExtendedEvent<XeSqlPkg::lock_acquired>. Nevertheless, both Profiler and Extended Events log the requested RangeS-S mode, not the resulting lock mode RangeX-X. This is counter to the limited documentation, which says:




            Mode | int | Resulting mode after the lock was acquired.




            The mode column of the extended event has no documentation at all, and the description in the meta data is blank. Perhaps Microsoft themselves weren't even sure of the behaviour.



            The mysterious LAST_MODE is something Erik Darling has remarked on before.



            I have often thought it would be more useful if lock events reported both the requested and resulting modes, but that is not what we have. The current arrangement makes it pretty much impossible to track and match up lock acquisition and release.



            There might be a good reason for reporting locks this way. If it doesn't meet your needs, you could open a support case with Microsoft.






            share|improve this answer





























              3














              The single row insert acquires an X (exclusive) lock on the new row.



              The SELECT attempts to acquire a range-shared, key shared (RangeS-S) lock.



              This request is reported by the lock_acquired Extended Event as mode = RS_S.



              It is reported by the Profiler event class Lock:Acquired as mode 13 (LCK_M_RS_S).



              The requested mode is combined with the existing exclusive lock mode in Lock::CalculateGrantMode in sqlmin.dll. There is no combined mode of range-shared, key exclusive (RangeS-X) so the outcome of the calculation is range-exclusive, key exclusive (RangeX-X), which happens to be mode 15.



              The grant mode calculation is performed just before the extended event is generated by lck_ProduceExtendedEvent<XeSqlPkg::lock_acquired>. Nevertheless, both Profiler and Extended Events log the requested RangeS-S mode, not the resulting lock mode RangeX-X. This is counter to the limited documentation, which says:




              Mode | int | Resulting mode after the lock was acquired.




              The mode column of the extended event has no documentation at all, and the description in the meta data is blank. Perhaps Microsoft themselves weren't even sure of the behaviour.



              The mysterious LAST_MODE is something Erik Darling has remarked on before.



              I have often thought it would be more useful if lock events reported both the requested and resulting modes, but that is not what we have. The current arrangement makes it pretty much impossible to track and match up lock acquisition and release.



              There might be a good reason for reporting locks this way. If it doesn't meet your needs, you could open a support case with Microsoft.






              share|improve this answer



























                3












                3








                3







                The single row insert acquires an X (exclusive) lock on the new row.



                The SELECT attempts to acquire a range-shared, key shared (RangeS-S) lock.



                This request is reported by the lock_acquired Extended Event as mode = RS_S.



                It is reported by the Profiler event class Lock:Acquired as mode 13 (LCK_M_RS_S).



                The requested mode is combined with the existing exclusive lock mode in Lock::CalculateGrantMode in sqlmin.dll. There is no combined mode of range-shared, key exclusive (RangeS-X) so the outcome of the calculation is range-exclusive, key exclusive (RangeX-X), which happens to be mode 15.



                The grant mode calculation is performed just before the extended event is generated by lck_ProduceExtendedEvent<XeSqlPkg::lock_acquired>. Nevertheless, both Profiler and Extended Events log the requested RangeS-S mode, not the resulting lock mode RangeX-X. This is counter to the limited documentation, which says:




                Mode | int | Resulting mode after the lock was acquired.




                The mode column of the extended event has no documentation at all, and the description in the meta data is blank. Perhaps Microsoft themselves weren't even sure of the behaviour.



                The mysterious LAST_MODE is something Erik Darling has remarked on before.



                I have often thought it would be more useful if lock events reported both the requested and resulting modes, but that is not what we have. The current arrangement makes it pretty much impossible to track and match up lock acquisition and release.



                There might be a good reason for reporting locks this way. If it doesn't meet your needs, you could open a support case with Microsoft.






                share|improve this answer













                The single row insert acquires an X (exclusive) lock on the new row.



                The SELECT attempts to acquire a range-shared, key shared (RangeS-S) lock.



                This request is reported by the lock_acquired Extended Event as mode = RS_S.



                It is reported by the Profiler event class Lock:Acquired as mode 13 (LCK_M_RS_S).



                The requested mode is combined with the existing exclusive lock mode in Lock::CalculateGrantMode in sqlmin.dll. There is no combined mode of range-shared, key exclusive (RangeS-X) so the outcome of the calculation is range-exclusive, key exclusive (RangeX-X), which happens to be mode 15.



                The grant mode calculation is performed just before the extended event is generated by lck_ProduceExtendedEvent<XeSqlPkg::lock_acquired>. Nevertheless, both Profiler and Extended Events log the requested RangeS-S mode, not the resulting lock mode RangeX-X. This is counter to the limited documentation, which says:




                Mode | int | Resulting mode after the lock was acquired.




                The mode column of the extended event has no documentation at all, and the description in the meta data is blank. Perhaps Microsoft themselves weren't even sure of the behaviour.



                The mysterious LAST_MODE is something Erik Darling has remarked on before.



                I have often thought it would be more useful if lock events reported both the requested and resulting modes, but that is not what we have. The current arrangement makes it pretty much impossible to track and match up lock acquisition and release.



                There might be a good reason for reporting locks this way. If it doesn't meet your needs, you could open a support case with Microsoft.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 hours ago









                Paul WhitePaul White

                57.9k15 gold badges304 silver badges477 bronze badges




                57.9k15 gold badges304 silver badges477 bronze badges






























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Database Administrators Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f244054%2fwhy-does-this-rx-x-lock-not-appear-in-extended-events%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

                    Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

                    19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу