SP_GETAPPLOCK - Parameters and long running

  • I've picked up a new client who is using Microsoft Dynamix on SQL Server 2012. They use a lot of SP_GETAPPLOCK, particularly against the ReqPlanVersion table, something like this:

    DECLARE @result int; EXEC @result = SP_GETAPPLOCK

    @resource = N'ReqPlanVersion:xxxx:ABCDE:123456',

    @lockmode = 'update',

    @locktimeout = -1;

    SELECT @result;

    This MS article https://msdn.microsoft.com/en-us/library/ms189823.aspx says the @locktimeout defines the timeout value in milliseconds, with 0 expressly defined, but I haven't found any definition of the behaviour if a negative value is supplied. My assumption would be: Never Timeout!

    Can anyone confirm this? Preferable with a reference to show the client.

    We have also picked up that every now and then the SP runs for hours. I've not had a chance to dig any deeper into the issue, but working on what I've been told there is no indication of blocking. My review of the situation seems to indicate that the resource is already locked by another user, so the lock request can't be satisfied. Since (I assume) a lock timeout of "infinite" is applied, the SP sits waiting for the resource to be released. Reading the article it sounds like we don't get a blocking alert because this SP is working at a very low level and it doesn't raise a blocking alert.

    Hope someone out there can fill in the gaps a bit.

    Leo

    Nothing in life is ever so complicated that with a bit of hard work it can't be made more complicated.

    Leo
    Nothing in life is ever so complicated that with a little work it can't be made more complicated.

  • I've been doing some testing and I can show that an @timeout argument = -1 causes the stored proc to wait until any existing locks with the same name are released. I've also pretty much shown from my testing that AX is requesting a lock resource with the same name twice although I now need to try find out where these are coming from within the app, and why the logic allows this. I suspect this is development on top of the core AX functionality, not AX itself.

    Cheers

    Leo

    Leo
    Nothing in life is ever so complicated that with a little work it can't be made more complicated.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply