How to reproduce a deadlock?

RemcoRemco Member Posts: 81
Can somebody give me a simple piece of code to create a deadlock.

I need to have a screenshot of a deadlock error.

Thanx. O:)

Answers

  • WaldoWaldo Member Posts: 3,412
    Didn't test this, but this should work:
    - In Client 1 lock record A and then a confirm
    - In Client 2 lock record B (other table) and then confirm
    - in Client 1, after confirm, lock record B
    - in client 2, after confirm, lock record A

    That's how I would test it... . :|

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • RemcoRemco Member Posts: 81
    Thanks Waldo, your solution worked!!
  • WaldoWaldo Member Posts: 3,412
    No problem 8) .

    May be you can paste your code here?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • RemcoRemco Member Posts: 81
    Codeunit 1:

    LocRecCustomer.LOCKTABLE;
    LocRecCustomer.GET('1');
    IF CONFIRM('Lock vendor record?',TRUE) THEN BEGIN
    LocRecVendor.LOCKTABLE;
    LocRecVendor.GET('500000');
    END;

    Codeunit 2:

    LocRecVendor.LOCKTABLE;
    LocRecVendor.GET('500000');
    IF CONFIRM('Lock customer record?',TRUE) THEN BEGIN
    LocRecCustomer.LOCKTABLE;
    LocRecCustomer.GET('1');
    END;
Sign In or Register to comment.