November 15, 2021

UNABLE_TO_LOCK_ROW, Unable to obtain exclusive access to this record exception in Salesforce

The error message "unable to obtain exclusive access to this record or 1 records:" indicates that a process was attempting to obtain a lock on a record for 10 seconds before eventually quitting the process with an error message indicating that the record is unavailable.
 
For consistent data, when a record is being created or updated, it is locked so that other users cannot update the record.

FOR UPDATE keyword in SOQL helps us to lock the records from being updating from another request. Sample Code - http://www.infallibletechie.com/2015/05/how-to-lock-records-using-apex-in.html

Locking Issue may happen due to Skewing issue - http://www.infallibletechie.com/2019/11/salesforce-data-skew.html

Salesforce Reference Link - https://help.salesforce.com/articleView?id=000338933&type=1&mode=1

1. Go to Background Jobs under setup and check whether any Sharing Rule Calculation or Picklist field list of value change is happening. If yes, wait for the jobs to complete.


2. Other user may also work on the same record at the same time. So, try after few minutes.

3. If you are using Bulk API for Data Loads, use Serial Mode instead of Parallel mode. If you want to use Parallel mode, make sure child records of the same parent are happening on the same batch of records.

No comments:

Post a Comment