About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
Salesforce returns the status code UNABLE_TO_LOCK_ROW, with a message that begins "unable to obtain exclusive access to this record", when a transaction cannot get a lock on a record in time, or when two transactions deadlock. Salesforce's help article says a transaction can wait a maximum of 10 seconds for a lock to be released before timing out. The cure is to find the competing update, usually on a shared parent record, and stop the two running at the same time.
What the error means
Salesforce places a lock on a record while it is being updated or created, to prevent concurrent operations from causing data inconsistencies. Salesforce's help article says these locks normally last a few seconds, and that a waiting transaction "can wait a maximum of 10 seconds for a lock to be released before timing out". If the lock is still held, the error is thrown. Salesforce's help article on row lock errors in master-detail relationships says the DML operation for the waiting record is rolled back to the previous savepoint.
The SOAP API guide describes the status code as "A deadlock or timeout condition has been detected." A deadlock involves at least two transactions updating overlapping sets of objects. The guide adds that if a transaction involves a summary field, the parent objects are locked, which makes these transactions especially prone to deadlocks. It says the timeout state "is temporary", and that "If an object in a batch can’t be locked, the entire batch fails with this error." The error text contains the IDs of the records that couldn't be locked, when available.
A Salesforce help article shows the wording in a real response from an upsert: the message "unable to obtain exclusive access to this record or 28 records", followed by a list of record IDs, with the status code UNABLE_TO_LOCK_ROW. The same article says the error "is not a defect; it just indicates the record was locked".
The parent record is the usual place. Salesforce's guide on record-level locking says that for objects with a master-detail relationship, when you update child records "the system locks the parent and the child records to prevent inconsistencies". Two situations carry the risk: updates to parent records and their children processed at the same time in separate threads, and updates to child records with the same parent processed at the same time.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| Parallel Bulk API batches share a parent | Some batches succeed, others report the code, and the failures cluster on a few parents | Records in different batches carry the same parent ID, and the job runs in parallel mode |
| An after-insert trigger on a child holds the parent for too long | Users editing the parent fail while a load runs | Debug logs for the failing user show the trigger running more than 10 seconds |
| Email-to-Case triggers on EmailMessage or related records | Errors cluster when many emails arrive | Triggers exist on EmailMessage or its parent Account |
| Master-detail parent with very many children | Lock errors on one popular parent | The parent has thousands of detail records edited together |
| A background job on the same object | Errors appear on a schedule | A job runs on the same object at the same time |
| Apex tests run against production data | Errors during test runs | Salesforce's help article notes that tests can cause locks |
| Operations known to increase contention | Errors when changing users, roles or sharing | The load creates users, updates roles, changes ownership with private sharing or changes territory hierarchies |
Prove the cause before changing anything
All steps read only.
- Copy the whole error row. Write down the status code, the message, the record IDs listed and the time.
- Find the records by ID in Salesforce and note whether they share a parent record, such as the same Account.
- If a Bulk API job is involved, read its concurrency mode. Salesforce says parallel is the default, and that in parallel mode "Any failed records must be resubmitted". Note how many batches ran at the same moment and whether their records point to the same parent.
- Check for background jobs on the same object that were running when the error happened.
- Count how often it happens. Salesforce says a small number of locking errors may be handled with retry logic, but frequent locking needs a change to how updates are sequenced.
If users are blocked while a load runs, Salesforce's help article says to enable debug logs for the user experiencing the error to identify the offending trigger, flow or validation rule. Enabling a debug log changes a setting in the org, so it is described here and not listed as a step. It belongs to the org's administrator.
Fix
Pick the fix by what the checks showed. Salesforce's own guidance for frequent locking from integrations and mass updates is to "sequence batches so that the same records aren’t updated in multiple threads simultaneously".
Sort the load so a parent's children stay in one batch
Salesforce's Bulk API guidance says that if you organise records by the parent ID so that all records referencing the same account are in a single batch, you minimise the risk of lock contention by multiple batches. The sorting happens on the input file, so a sorted copy leaves the original as the record of what was exported. Salesforce adds that failed records are not retried by the Bulk API and must be submitted again in a separate batch.
Our own advice: the load is a data change in Salesforce, so agree it with the data owner before it runs.
This is described and not listed as a step. Loading the sorted copy changes records in Salesforce, and a load cannot be undone, so rows that were loaded stay loaded. Rows that failed must still be resubmitted. The original file is not changed, so it stays the record of what was exported.
Reduce the batch size or switch to serial mode
Salesforce's help article lists three choices for Bulk API loads: reduce the batch size, process in serial mode, and sort records by parent ID. Serial mode processes batches one at a time, and Salesforce says the cost "is an increase in processing time". It also says to avoid serial mode unless parallel mode would otherwise result in lock timeouts and you can't reorganise your batches. In Data Loader the setting is Enable serial mode for Bulk API, under Settings, available when Use Bulk API is selected.
First save the current state: write down whether Enable serial mode for Bulk API is ticked in Data Loader Settings, and the time.
Risk: Serial mode makes the load slower, because each batch must finish before the next starts. A nightly load that fits its window in parallel may overrun it.
In Data Loader, choose Settings, then Settings, tick Enable serial mode for Bulk API, and select OK.
Write down the rows that failed, from the failed run's result file, and the time.
Risk: Rerunning the failed rows loads data into Salesforce, and a load cannot be undone: rows that load stay loaded. Agree it with the data owner first.
Run the load again with only the rows that failed.
Risk: Only if you need to back out. Turning serial mode off changes how every later load with these settings runs, and locking errors may return.
Open Settings, then Settings, set Enable serial mode for Bulk API to the value you wrote down, and select OK.
Shorten the trigger or reduce children per parent
Salesforce's help article says to reduce Apex trigger execution time, and to avoid or minimise the use of locking statements in triggers. For a master record with thousands of detail records, it says to distribute the children across more parents. Both are code or data-model changes that depend on your org, so they are described and not listed as steps.
Pause a competing job
The help article says to check for dependent background jobs on the same object and, if any are running, pause them and retry. Pausing a job belongs to its owner, so decide with them when it can run.
Example (illustrative): the finance team at Example Pty Ltd loads 10,000 Task rows each night from app01 with Data Loader and Bulk API, in 5 batches of 2,000 (10,000 ÷ 2,000 = 5). The batches run in parallel and one fails with UNABLE_TO_LOCK_ROW, listing one Account ID. The file is in the order the source system exports it, so rows for the same Account sit in different batches. The administrator keeps the original file, sorts a copy by Account ID so each Account's rows fall in one batch, loads the copy in parallel, and resubmits the failed rows.
Confirm the fix
- Read the job results of the load you ran in the fix. No rows report UNABLE_TO_LOCK_ROW.
- Count the rows: loaded plus resubmitted equals the rows in the source file.
- If you changed serial mode, compare the new run time with the load window.
Salesforce says to always test your data loads in a sandbox organization first. Our own advice: a further load, or a user editing a parent record while a load runs, changes data, so try that in a sandbox only.
What to watch afterwards
- Keep a short note of which loads touch which parent objects, and when they run, so that two never overlap on the same records.
- Add retry logic to integrations. Salesforce says small numbers of locking errors can be handled that way.
- Watch triggers on child objects after each release, since added logic lengthens the time the parent stays locked.
- For rate-limit style errors on another CRM, see HubSpot API 429 "You have reached your daily limit.": tell the daily limit from the TEN_SECONDLY_ROLLING limit.
Read next
Related articles you may want next.
- TroubleshootingHubSpot API 429 "You have reached your daily limit.": tell the daily limit from the TEN_SECONDLY_ROLLING limitHubSpot API 429 You have reached your daily limit: read policyName, tell daily from ten-second limits, then throttle, batch or cache.Read article
- TroubleshootingPower Automate "429 (Too Many Requests)" and "Rate limit is exceeded": why a flow is throttled and what to changePower Automate 429 Too Many Requests, Rate limit is exceeded: read the connector limit, count calls per minute, then lower loop concurrency.Read article
- TroubleshootingDataverse error 0x80040220 PrivilegeDenied: find the security role that lacks the privilegeDataverse error 0x80040220 PrivilegeDenied: read the message, check the user's security roles in the admin center, then fix the role or assignment.Read article
Risks and limits
- None of these steps have been run or lab-tested.
- Salesforce says the timeout state is temporary and that no corrective action is needed once the lock clears, so one-off errors do not always need a change.
- Serial mode trades speed for fewer locks. Salesforce says to avoid it unless parallel mode causes lock timeouts.
- Which operations lock which records depends on your data model, and Salesforce says it can't predict exactly when contention occurs in your org.
Sources
- Core Data Types Used in API Calls — Salesforce SOAP API Developer Guide, no date shown, accessed 4 December 2026
- Salesforce Error 'Unable to lock row - Record currently unavailable' — Salesforce Help, published 28 May 2026, accessed 4 December 2026
- Mule 4 Salesforce Upsert Error "Unable to obtain exclusive access to this record" and "UNABLE_TO_LOCK_ROW" — Salesforce Help, published 18 March 2026, accessed 4 December 2026
- Salesforce DML: Order of Execution When a Row Lock Error Occurs in Master-Detail Relationships — Salesforce Help, published 2 June 2026, accessed 4 December 2026
- Record-Level Locking — Designing Record Access for Enterprise Scale, Salesforce Developers, no date shown, accessed 4 December 2026
- General Guidelines for Data Loads — Bulk API 2.0 and Bulk API Developer Guide, Salesforce Developers, no date shown, accessed 4 December 2026
- Configure Data Loader — Data Loader Guide, Salesforce Developers, no date shown, accessed 4 December 2026
This article was originally published on .