Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!
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?
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.
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?
Thank you for you answers! I will try again with the new approach and I will come back with my feedback.
Do you have any update? Does this work for you?
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.