function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dave Pattison 6Dave Pattison 6 

How can we find out what was locking our record, resulting in Unable to Lock Row errors?

Hello, Dev Community

We intermittentlly get this error when inserting child records of some master/detal objects whose parent is a Case record.

We have reviewed the Force.com Record Locking Cheatsheet, but our data model is very complex and there is a lot of workflow/trigger code coming from multiple teams, not to mention managed package code and potentially batch operations too.

So tracing the actual root cause for UNABLE_TO_LOCK_ROW can be very difficult and time consuming.

What I'm asking for, is some way to programatically (or otherwise) determine some context of the operation and user id of the thread that was locking the record (and thus prevented our code from executing successfully). This would make diagnosing such issues much more straightforward!
 
Can anyone help?