My Account | Internet Creations
Welcome, Guest.

UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record

Symptoms

Cases are not created, and in some instances, emails received related to existing cases fail to be processed and the following error is sent to the email address configured in "Route Error Emails to This Email Address":
The attached message was sent to the Email Service address 
<e2cpremium@xxxxxxxxxxxxx.apex.salesforce.com> 
but could not be processed because the Apex class: E2CP.ProcessMessage failed with the following error: 
System.DmlException: Insert failed. First exception on row 0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: [] 

Similar errors are returned when using Email to Case (standard) and other custom Apex Email Services.

Solutions

Unfortunately this error is the result of a resource contention on the Force.com platform and there is no perfect solution that we can provide. The likelihood of encountering this error increases with the concurrency of emails received and automation that runs for each email received.

The following tips might help reduce the occurrences of this issue. We realize that they might be impractical or impossible to implement and wish there was a perfect solution to offer.

Email Volume
  • Limit email volume where possible, particularly emails sent from the same Contact/Account. For example, if you have automated alerts sent to Salesforce, reducing duplication and varying the sender may help.
  • Reduce email batch sizes where possible. Two batches of 5 emails several minutes apart are much less likely to result in an error than one batch of 10.

Automation (Apex Triggers, Workflow Rules, Rollup Summaries)
  • 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.
Internet Creations has created a "retry" feature specifically for Email to Case Premium that provides a work around in most instances. Contact Internet Creations support for enablement instructions and considerations.

Status

This is a known limitation on the Force.com platform. A number of factors that contribute to this issue making it impossible to predict how many emails can be processed concurrently without error.


2/18/2018 - Although we have not observed any regression, we have no plans to remove "beta" classification due to the nature of this solution and it will remain unsupported.
1/31/2014 - Internet Creations has created a "retry" feature that provides a work around in most instances.

Additional Information

https://help.salesforce.com/articleView?id=000229525&type=1
https://success.salesforce.com/issues_view?id=a1p30000000T3UYAA0
 

Support

Open a Case