Skip to main content

Resolving "TooManyLockFailure" when deploying data

Resolving "TooManyLockFailure" when deploying data

Ben Thompson avatar
Written by Ben Thompson
Updated this week

Error overview and explanation

The TooManyLockFailure 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. If too many records in a batch have this error, then the TooManyLockFailure is thrown.
​

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, or using the SOAP API (configurable from your account settings).

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?