In Mulesoft, when trying to UPSERT records in a Salesforce Object, the records are getting locked.
After enabling Salesforce DEBUG logging (by following this Knowledge Article), you will see something like the following in the application log:
DEBUG 2020-03-26 11:18:35,857 [[MuleRuntime].io.03: [htb-salesforce-diff-process-api00248611].htb-salesforce-diff-process-upload-accounts.BLOCKING @7378920d] [event: 05ebe7d0-6f73-11ea-8a35-24418cf673a5] org.mule.extension.salesforce.internal.connection.provider.ConnectorConfigBuilder: Receiving response from https://haventreebank--uatfull.my.salesforce.com/services/Soap/u/47.0/00D4g0000008y62 DEBUG 2020-03-26 11:18:35,857 [[MuleRuntime].io.03: [htb-salesforce-diff-process-api00248611].htb-salesforce-diff-process-upload-accounts.BLOCKING @7378920d] [event: 05ebe7d0-6f73-11ea-8a35-24418cf673a5] org.mule.extension.salesforce.internal.connection.provider.ConnectorConfigBuilder: <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header><LimitInfoHeader><limitInfo><current>2443</current><limit>5000000</limit><type>API REQUESTS</type></limitInfo></LimitInfoHeader></soapenv:Header><soapenv:Body><upsertResponse> <result><created>false</created><errors><message>unable to obtain exclusive access to this record or 28 records: 001f100001NuTxXXXX,001f100001NuYcXXXX,001j000000YaLXXXX,001j000000IO3HXXXX,001f100001MSRDfXXX,001j000000IO3J1XXX,001j000000J0030AAB,001f100001NudDr,001f100001MSS1y,001f100001MSWmj, ... (18 more)</message><statusCode>UNABLE_TO_LOCK_ROW</statusCode></errors><id xsi:nil="true"/><success>false</success></result> <result><created>false</created><errors><message>unable to obtain exclusive access to this record or 28 records: 001f100001NuTxXXXX,001f100001NuYcXXXX,001j000000YaLXXXX,001j000000IO3HXXXX,001f100001MSRDfXXX,001j000000IO3J1XXX,001j000000J0030AAB,001f100001NudDr,001f100001MSS1y,001f100001MSWmj, ... (18 more)</message><statusCode>UNABLE_TO_LOCK_ROW</statusCode></errors><id xsi:nil="true"/><success>false</success></result> <result><created>false</created><errors><message>unable to obtain exclusive access to this record or 28 records: 001f100001NuTxXXXX,001f100001NuYcXXXX,001j000000YaLXXXX,001j000000IO3HXXXX,001f100001MSRDfXXX,001j000000IO3J1XXX,001j000000J0030AAB,001f100001NudDr,001f100001MSS1y,001f100001MSWmj, ... (18 more)</message><statusCode>UNABLE_TO_LOCK_ROW</statusCode></errors><id xsi:nil="true"/><success>false</success></result> ...
Using MuleSoft, when the error UNABLE_TO_LOCK_ROW is detected on the Salesforce side, that indicates the desired Salesforce record was locked by other sessions during the bulk update.
Please refer to the below Salesforce Help doc for more detail:
Salesforce Help: Unable to lock row - Record currently unavailable errors
The error itself is not a defect; it just indicates the record was locked. With Mule 4, the lock error should be investigated from Salesforce perspective, but here are some generic assumptions.
To reduce the frequency of the error, there are two points to consider:
1) Reduce the processing time for the update transaction. As the update transaction completes quickly, there will be a lower risk of being locked.
- By reducing the batch size, it will decrease the number of records to be updated in one transaction, so update transaction time will be reduced.
- Are there Apex triggers associated with the desired Salesforce record/object? Look into such Apex triggers if there are some triggers that may cause a longer time to complete the update.
2) Reduce the possibility of concurrent updates to related records
- Is there a parent/child relationship on the desired Salesforce record/object, such as Account and Contact, and some custom Salesforce objects, etc.? Please look into your Salesforce transaction during the bulk update that may update such related/parent/child records to reduce the risk of lock contention.
- Also, if you have associated Apex triggers to the desired record to be updated, check if there are any other Salesforce objects to be updated by the trigger and avoid updating such objects during your bulk update.
001122237

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.