E2120 Unable to lock row

When a record is being updated or created, Salesforce will place a lock on that record to prevent another operation from updating the record at the same time and causing inconsistencies on the data.These locks normally last for a few seconds and when the lock is released, other operations can do any processing they are supposed to do on the record in question. However, a given transaction can only wait a maximum of 10 seconds for a lock to be released, otherwise, it will time out.

E2120 - ECE_SForceDataError: We got an error back from SalesForce when trying to update or insert data in SalesForce: Error returned from SFDC on update: [message: unable to obtain exclusive access to this record , statusCode: UNABLE_TO_LOCK_ROW ] , Data sent: sObjects: [type: Product2 , Id: 01t0000000DYg06AAD , Cost__c: 44.00 ]

Therefore, the below error is caused by the following:

  • Either background jobs running at the same time or other external systems which are trying to create or update the same record. And in this case, it's important to check for any jobs running on the specific object;
  • Or when inserting a batch of child records, Salesforce may attempt to add records in parallel to a single parent record, generating this error when one insert has locked the parent and a second record also attempts to lock it. In order to insert a batch of child records, the Commit Per should be set to 1 so Salesforce can handle them separately.