Record Locked By Another User

Jonathan2708Jonathan2708 Member Posts: 552
Hi,

I have a scheduled NAS task which creates sales invoices and credit memos from another data source. The task runs once a day and everything has been running fine. However today the task failed with the error "The Sales Line table cannot be changed because it is locked by another user. Wait until the user is finished and then try again". This error actually happened once before, but it's only 2 times in the last 5 months.

I'm guessing that right at the point the NAS task is inserting a new sales line, another user has tried to do the same thing and it's caused this locking error. Can anybody suggest the approach to resolve this? Do I need to use LOCKTABLE in my invoice creation code?

I'm using NAV 6.00, on SQL Server 2008.

Any help appreciated,

Jonathan

Comments

  • strykstryk Member Posts: 645
    Hi Jonathan,

    well, I'm not sure if this error refers to a "Lock Timeout" (are you using this?) or a "Deadlock".
    If it's due to a "Locktimeout" then maybe you could disable it for this NAS processing by inserting this piece of code; for example:
    LOCKTIMEOUT(GUIALLOWED);
    
    Means the timeout is disabled for non-GUI processing by the NAS.

    If it was a "Deadlock", then you need to do further investiagtions to identify the "counterparts" and the code which was responsible;
    this might help you: http://dynamicsuser.net/blogs/stryk/archive/2008/11/03/blocks-amp-deadlocks-in-nav-with-sql-server.aspx

    Of course, LOCKTABLE commands can be responsible for blocking/deadlocking (see my BLOG), but you cannot simply remove it: many LOCKTABLEs are required to maintain data-integrity and are indeed necessary.
    Whether LOCKTABLE could be removed or not requires some further investigation and analysis.

    Best regards,
    Jörg
    Jörg A. Stryk (MVP - Dynamics NAV)
    NAV/SQL Performance Optimization & Troubleshooting
    STRYK System Improvement
    The Blog - The Book - The Tool
  • knolvskyknolvsky Member Posts: 10
    hii..

    i have the same problem with my NAV 5...and then i got my problem solve \:D/ \:D/

    i kick the other user that use my ID login..(file-->database-->information--->sessions--->and lookup)

    and then wooss...there is no problem again..

    REASON :

    maybe the other person user my ID and we edit the same thing..
Sign In or Register to comment.