Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
cristeam
Contributor
Contributor

UNABLE_TO_LOCK_ROW:unable to obtain exclusive access to this record or 180 records:

Hi!

I have a job that inserts some records in empty Salesforce table Contact using tSaleforceOutputBulkExec from csv file. The import usually works, with Contact or other tables. However, I got a bunch of errors like UNABLE_TO_LOCK_ROW:unable to obtain exclusive access to this record or 180 records. The org that I'm using is a sandbox and the imports are made from one place, so I would exclude the case that someone else is using the same records in the same time.

Has anyone a hint why is this happening? The same records I imported later with DataLoader.

 

Thank you and happy coding!

 

Labels (4)
1 Solution

Accepted Solutions
JR1
Creator III
Creator III

Have you tried to add a tSortRow before the import to sort the contacts by their parent accounts? If you are assigning Contacts to the same Account in multiple batches, the first batch that gets there wins and thus the next one will not be able to lock the Account if you run the Bulk API in parallel mode. By sorting them, you make sure that an Account is only locked in one batch (most of the time). DataLoader should show the same behaviour but maybe you are running it in serial mode?

View solution in original post

5 Replies
TRF
Champion II
Champion II

This may arrive depending on the triggers, process builder and so on fired when records are inserted/updated.

When you insert a Contact record, you attach it to its Account and it's possible that lock on this object cannot be obtained.

You can try to reduce the batch size (but this will increase the elapse time).

As I remember, you may also activate logs on salesforce side to discover which object cannot be locked and what component are fired when your job runs.

JR1
Creator III
Creator III

Have you tried to add a tSortRow before the import to sort the contacts by their parent accounts? If you are assigning Contacts to the same Account in multiple batches, the first batch that gets there wins and thus the next one will not be able to lock the Account if you run the Bulk API in parallel mode. By sorting them, you make sure that an Account is only locked in one batch (most of the time). DataLoader should show the same behaviour but maybe you are running it in serial mode?

cristeam
Contributor
Contributor
Author

Thank you for you answers! I will try again with the new approach and I will come back with my feedback.

JR1
Creator III
Creator III

Do you have any update? Does this work for you?

cristeam
Contributor
Contributor
Author

Hello!

I made a new import using the tSort. All records were imported and it seems that the problem was solved.

Thank you very much for your help.