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
NAIT ConsultingNAIT Consulting 

Hi All, Can anybody explain about this error in Email-to-case? UNABLE_TO_LOCK_ROW : unable to obtain exclusive access to this record or 1 records: 0039000002OGGACAA5

Hi All,

We received the following error in the email to case UNABLE_TO_LOCK_ROW : unable to obtain exclusive access to this record or 1 records: 003XXXXXXXXXXXXX
This only happened some of the time (not always) and particularly when there is an email sent to both of our email-to-case address.
After tracing it seems like the record failed to be locked is Contact record, however, we don't have any logic that requires to update a contact in Email-to-case process.
Appreciate any help / input, since we cannot log this case to SF support.
NagendraNagendra (Salesforce Developers) 
Hi,

This Issue is likely to happen if your data skew in the system, where a single Record( let say Account) is associated with multiple child records(more than 10000) which causes record lockout problem.

Now in the email to case scenario  if multiple transactions are happening concurrently and all are trying to create contacts/cases( with same account record on lookup field) then there is always a small probability that one transaction holding the lock on particular account record will put the other transaction in record lockout phase( just because of skew).

Generally, salesforce platform processes more than billion transactions per day with an average response time of less than 300 milliseconds and database holds a lock for a very short amount of time but due to skew which causes some lock contention and reduce database concurrency.

For more information with a similar discussion please check with below link.
Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
 
NAIT ConsultingNAIT Consulting

@Nagendra, So you are meaning to say that it is probable but not always?

Because I tried several times in our sandbox (exact replica of Production) and it doesn't occur.
So how do we prevent this? 
I am afraid that the answer is we cannot after reading the link you provided (it only state to reduce, not actually prevent it)