What is 'UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record' error and how to resolve it?
Sometimes emails do not create expected records (or attach with the existing records) and land into the e2a Unmatched Emails queue, showing ‘Insert failed. First exception on row 0: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record’ error as the reason for not being processed.
Generally, this issue arises when more than one operations are trying to acquire a same resource at the same time (Resource contention). Probability of facing this error increases with the concurrency of emails received and if the following automations are in place to process the emails.
- Validation Rules
- Workflow Rules
- Rollup Summaries
This is a known limitation on the Salesforce platform. However the following tips might help reduce the occurrences of this issue and we wish there was a perfect solution available.
Remove automation that is no longer used and is only increasing overhead.
Ensure Apex Triggers are as efficient as possible. Using future methods may help as well.
Remove all Rollup Summaries that are not needed.
- Check for any dependent background jobs that are running on the same object. If there is any, try to pause the jobs and then perform the actions to reduce row locks.
- To avoid the resource contention, optimize/minimize the automations to the best possible extent (which are in place to process the emails).
Our support team would be happy to investigate and help you in finding the root cause if you are facing the same error but not sure what automation is causing the error.
Please contact us at firstname.lastname@example.org for any questions.
★★★★★ - EXCELLENT
★★★★☆ - GOOD
★★★☆☆ - OK
★★☆☆☆ - POOR
★☆☆☆☆ - RUBBISH