Strange Locking Message

ta5ta5 Member Posts: 1,164
Hi
We have a strange locking message in our customized code.

"The xy table cannot be locked or changed because it is already locked by the user with the id zz. Waint until the user is finished an then try again."

It is a message or an error, but not the common text shown in the status line at the bottom of the active window. The common text is "The xy table is locked by ab, press crtl+break to cancel..."

BTW: The text is located in fin.etx.

Anybody knows under what circumstances the message is shown (instead of the "normal" message?

Thanks in advance

Thomas

Comments

  • bbrownbbrown Member Posts: 3,268
    This message will result when you set LOCKTABLE(FALSE).
    There are no bugs - only undocumented features.
  • DenSterDenSter Member Posts: 8,305
    I believe that is the message that you get when a lock takes longer than the value in the lock timeout property.
  • kinekine Member Posts: 12,562
    It is different for Native DB and MS SQL. MS SQL will not give you this info, because the wait is processed by MS SQL server and NAV client do not know about it. if you are using Native, NAV will show you this message...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ta5ta5 Member Posts: 1,164
    Hi
    I can reproduce the message if the table is locked and another process issues the locktable(false) command.
    It's a native db.

    However, there are some open questions:

    1) In our customized code there is NO locktable(false). Without locktable(false) the error is not reproducable in my dummy codeunits. So I still wonder why this error occurs in our customized codeunits.

    2) I have 2 Codeunits
    This is Codeunit-1
    table.init;
    table.pk := 'a';
    sleep(10000);
    table.insert
    

    While Codeunit-1 is idling, codeunit-2 issues table.locktable without an error. I guessed that there would be an error because transaction from Codeunit-1 is not finished then.

    Hope somebody could bring some light in these misterious matter :?
  • DenSterDenSter Member Posts: 8,305
    Locking is not done only as a result of the LOCKTABLE command. When you have process 1 modifying a record, and then process 2 modifying the same record, without updating that record with the modifications of process 1, then you get a locking error. It's database management, it's how your data is kept consistent.

    You need to make your custom code aware of other processes, and either pass the record by reference or get the record again right before you modify it.
  • ta5ta5 Member Posts: 1,164
    Hi David
    Thanks for your explanations.
    But I still dont get the point why

    a)... it's not possible to reproduce the originally posted error msg
    and
    b)...I don't get an error message with my 2 Codeunits configuration. I thought that while Codeunit-1 is sleeping, the transaction is still open and no other proces could lock that table.

    Regards
    Thomas
  • DenSterDenSter Member Posts: 8,305
    the LOCKTABLE is not the time that it actually locks the table, it prepares the query to do it once you issue a MODIFY. In your codeunit 2 you could try modifying the record that you insert in codeunit 1, although I'm not sure if that will work.
Sign In or Register to comment.