Skip to main content

Resolving "UNABLE_TO_LOCK_ROW: Unable to Obtain Exclusive Access to This Record" when deploying data

How to resolve "UNABLE_TO_LOCK_ROW" error surfacing during data deployments

David Martin avatar
Written by David Martin
Updated over 2 months ago

Error overview and explanation

The "UNABLE_TO_LOCK_ROW" error occurs when a process is attempting to lock a record for an update, but another process is already locking the same record.
​
If the lock is not released within 10 seconds, the transaction times-out, resulting in this error.
​

An example is when records are updated using Bulk API which Gearset uses to deploy data, multiple batches run in parallel. If two batches update child records linked to the same parent, one batch will lock the parent, causing the other batch to fail with the lock error.


Resolution

To resolve this, consider reducing the batch size, which minimizes record contention by processing fewer records at once.

Additionally, sorting records by their parent record before processing can help avoid different batches updating the same parent at the same time. If possible, avoid nested transactions that update both parent and child records simultaneously, as this increases the likelihood of lock contention.


Background tasks

Another step is to check for background jobs that might be locking records. Identifying scheduled jobs that run at the same time as updates can help identify potential conflicts.

If necessary, pausing long-running jobs before retrying the update can confirm whether they are causing the issue.
​

Enabling debug logs is another useful troubleshooting step. This can help identify If another process is holding a lock on these records.

Did this answer your question?