web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Locking /deadlock in Ax2012 (delete_from in BatchServer

(0) ShareShare
ReportReport
Posted on by 1,535

I’m changing process to multi-thread process. I changed process with class Thread and working ok, now I want to change using Batch Server (class run on a server, CIL). I have a problem with multiple batches at the same time. Problem is a deadlock.

Batch1:
Delete_from Tab1 exists join Tab2 where Tab1.id = Tab2.id and Tab2.Group=’AAA’

Batch2:
Delete_from Tab1 exists join Tab2 where Tab1.id = Tab2.id and Tab2.Group=’BBB’

 

In this scenario I have a problem (infolog):
Cannot delete a record in @... (Tab1). Deadlock, where one or more users have simultaneously locked the whole table or part of it.

Microsoft.Dynamics.Ax.Xpp.DeadlockException: Exception of type 'Microsoft.Dynamics.Ax.Xpp.DeadlockException' was thrown. at Microsoft.Dynamics.Ax.MSIL.Interop.throwException(Int32 ExceptionValue) at Microsoft.Dynamics.Ax.MSIL.cqlCursorIL.DeleteAll(IntPtr table)

   at Dynamics.Ax.Application….() in ….xpp:line …

 

After changing my methods like below everything is OK:

Batch1:

Select forUpdate Tab1 exists join Tab2 where Tab1.id = Tab2.id and Tab2.Group=’AAA’

{ Tab1.doDelete()}

Batch2:

Select forUpdate Tab1 exists join Tab2 where Tab1.id = Tab2.id and Tab2.Group=’BBB’

{ Tab1.doDelete()}

 

Why delete_from … is wrong in CIL in BatchServer?

*This post is locked for comments

I have the same question (0)
  • nmaenpaa Profile Picture
    101,162 Moderator on at

    Maybe a lock escalation occurs. You can use trace flag 1224 to relax the lock escalation rules in SQL Server.

    blogs.msdn.microsoft.com/.../sql-server-lock-escalation-and-blocking

  • Mea_ Profile Picture
    60,284 on at

    Also check that you have an index by id and Group fields and add

    catch (Exception:Deadlock)
    {
       retry;
    }


    to handle it.

  • Ireneusz Smaczny Profile Picture
    1,535 on at

    I changed flag 1224 (DBCC TRACEON (1224, -1);) but nothing changed.

    I added try {} catch (Exception::DeadLock) but I still have deadlock in the same select :-(

    Any help?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans