How to Fix UNABLE_TO_LOCK_ROW Error in Salesforce?

What is UNABLE_TO_LOCK_ROW Error in Salesforce?

The Salesforce UNABLE_TO_LOCK_ROW error occurs when Salesforce is unable to obtain an exclusive lock on a record during an update operation. To ensure consistency, Salesforce automatically locks a record when it is being updated.

If any other user, automation or integration tries to modify the same record at the same time, Salesforce throws the UNABLE_TO_LOCK_ROW error to avoid conflicting updates.

The error typically appears as:

  • UNABLE_TO_LOCK_ROW: unable to obtain exclusive access to this record

Why Does UNABLE_TO_LOCK_ROW Occur?

This is commonly caused by concurrent processing. For your reference, here are the most common reasons of UNABLE_TO_LOCK_ROW error:

1. Parallel Batch Apex Jobs

If multiple batch jobs attempt to write to the same parent or related records, Salesforce can’t lock and throws UNABLE_TO_LOCK_ROW

2. Integration Conflicts

External systems syncing data in real time can attempt to update the same record as internal automation. This overlap often triggers the UNABLE_TO_LOCK_ROW error

3. Record-Triggered Flows and Triggers

In concurrent transactions, if multiple Flow or Apex triggers try to write to the same record, you may experience an UNABLE_TO_LOCK_ROW error.

4. Bulk Data Operations

Large data imports by Data loader or Bulk API has higher record contention risk that can lead to UNABLE_TO_LOCK_ROW when related objects are involved.

5. High Data Volume Environments

High-volume transaction organisations are more susceptible to UNABLE_TO_LOCK_ROW due to concurrent updates.

Where Does UNABLE_TO_LOCK_ROW Commonly Appear?

You are most likely to see UNABLE_TO_LOCK_ROW in the following scenarios:
  • Apex batch classes
  • Scheduled jobs
  • Record-triggered Flows
  • Bulk API operations
  • Data migration projects
  • Integration platforms updating Salesforce concurrently

UNABLE_TO_LOCK_ROW error is common in enterprise environments with heavy automation.

How to Fix UNABLE_TO_LOCK_ROW in Salesforce

Solve UNABLE_TO_LOCK_ROW, reduce record contention and improve automation? Here are strategies to help you.

1. Reduce Parallel Processing

Avoid running multiple batch jobs or integrations simultaneously on the same object.

2. Use Serial Mode in Bulk API

Switching from parallel mode to single-threaded mode mitigates the locking conflict that results in UNABLE_TO_LOCK_ROW.

3. Optimise Batch Size

Using smaller batches lessens the chances of record contention and fewer UNABLE_TO_LOCK_ROW.

4. Implement Retry Logic

Many integrations can retry failed operations automatically. A retry mechanism often resolves temporary UNABLE_TO_LOCK_ROW errors.

5. Review Automation Architecture

Review Flows, Process Builders, and Triggers that may be updating the same records.

Best Practices to Prevent UNABLE_TO_LOCK_ROW

To prevent UNABLE_TO_LOCK_ROW in production environments:
  • Design automation carefully to avoid simultaneous updates
  • Schedule batch jobs during low-traffic hours
  • Avoid unnecessary parent record updates
  • Monitor debug logs for locking patterns
  • Minimise overlapping integrations
A well-architected system significantly reduces the frequency of UNABLE_TO_LOCK_ROW errors.

Conclusion

The UNABLE_TO_LOCK_ROW error is built into Salesforce to help protect your data. We understand that you can get interrupted integrations and automation, but with the right architecture, proper serial processing, and well-optimised batch execution, this can be largely minimised.Understanding the root cause of UNABLE_TO_LOCK_ROW allows admins and developers to build more scalable and reliable Salesforce solutions.

Get the latest tips, news, updates, advice, inspiration, and more….

Need help fixing this in your org?

Our Salesofrce experts can debug and resolve this issue quickly.