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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

What happens when a SysOperation job that updates a table fields is been run simultaneously by two users

(0) ShareShare
ReportReport
Posted on by 115

Currently we have a sysOperation job in which we are deleting the records in a table and inserting new calculated fields in a service class. We are not using any ttsbegin ttscommit or putting it inside a try catch. I am just trying to understand how will the system work if two or more users run the service class simultaneously at the same time. Are there any preventive measures that we could take to avoid such situation? 

I have the same question (0)
  • JohnBright Profile Picture
    115 on at

    Thank you Martin for your time, will do the same.

  • Verified answer
    Martin Dráb Profile Picture
    238,308 Most Valuable Professional on at

    If you always want to use the table(s) in this way, disabling OCC directly on the table is the easiest way.

  • JohnBright Profile Picture
    115 on at

    Hi Martin, Sorry that I didn't mentioned in my previous comment. In our service class we are performing multiple insert_Recordset operation and update_recordset operation on different groupings of records. I have seen code to set pessimistic locking in select statements but not sure how to activate the pessimistic locking for inser_recordset or Update_recordset. Please can you advice on that?

    Also, will changing the table property OCC enabled to no will do the trick on pessimistic locking?

  • Martin Dráb Profile Picture
    238,308 Most Valuable Professional on at

    That's a simple scenario. Do the work in a transaction and use pessimistic locking.

    When the second session tries to delete data from the table, it'll be blocked until the exclusive lock is released. When the original transaction completes, the second sessions continues - it deletes all the records created a moment ago and runs the same logic to generates them once more.

  • JohnBright Profile Picture
    115 on at

    Hi Martin, thanks for your response. 

    For the first question, we are not generating any user specific data. All users have the same set of data. 

    For second question, Yes when two users launches the batch job I want the second user's batch to wait and then run once the first user's job get's over. Can you please advice on how can we achieve this? 

  • Martin Dráb Profile Picture
    238,308 Most Valuable Professional on at

    It depends on what you want to achieve. If you want each users to have a separate set of data, then your design is wrong and you'll need to come with a different one. For example, you may want to use a temporary table, partition data by user ID or a session ID or so.

    If all users should use the same same set of data and you just want to prevent multiple refreshes at the same time, decide that should happen. For example, if you run the job and another is already running, does it make sense to wait for completion and immediatelly running the same thing again? Or what should happen?

    I suspect that you really need to redesign the thing. It doesn't sound like something designed for a multi-user system.

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

News and Announcements

Season of Giving Solutions is Here!

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 417 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 325 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans