You need to sign in to do that
Don't have an account?

Upsert Error: "unable to obtain exclusive access to this record"
I'm seeing this error relatively frequently as I attempt to upsert data to Salesforce. However, it isn't 100% repeatable - if I try to run the same batch job again it is a different set of records that fails to upsert.
Some notes on our upload process:
1. We are using multi-threading to increase upload speed.
2. We are *not* upserting the same record at the same time with multiple threads. (A given record only appears once in the batch upload process).
3. The object we are upserting to does have an Apex trigger on it - but this trigger only modifies the record being updated, so we should not run into any locking issues here.
4. The object we are upserting is included in a roll-up summary.
I'm thinking that maybe it's the parent in the roll-up summary that is being locked? Does this sound plausible?
I'll be investigating further. Just wondering if anyone else has ever run into this error...
-Greg
Message Edited by glorge on 11-12-2008 05:10 PM
Some notes on our upload process:
1. We are using multi-threading to increase upload speed.
2. We are *not* upserting the same record at the same time with multiple threads. (A given record only appears once in the batch upload process).
3. The object we are upserting to does have an Apex trigger on it - but this trigger only modifies the record being updated, so we should not run into any locking issues here.
4. The object we are upserting is included in a roll-up summary.
I'm thinking that maybe it's the parent in the roll-up summary that is being locked? Does this sound plausible?
I'll be investigating further. Just wondering if anyone else has ever run into this error...
-Greg
Message Edited by glorge on 11-12-2008 05:10 PM
Interestingly, I have not been able to reproduce the issue in our Sandbox. Therefore, I wasn't able to confirm that it was specifically the combination of multi-threading and roll-up summaries that was causing the problem. Since things had been running fairly stable (with multi-threading) until I changed a couple of lookup relationships into master-detail relationships, though, I'm inclined to think that must be the problem.
Overall, given the amount of the trouble I've gotten myself into with multi-threaded upserts, I plan to follow your advice in the future and look for other ways to save time.
Thanks again,
Greg
After reading through the API for a bit I found this...
"Deadlocks involve at least two transactions that are attempting to update overlapping sets of objects. Note that if the transaction involves a summary field, the parent objects are locked, making these transactions especially prone to deadlocks. To debug, check your code for deadlocks and correct. Deadlocks are usually not the result of an issue with Salesforce operations."
If I'm upserting a block of 200 records, any number of which may share the same parent (and factor into the same roll-up summary, which in turn drives a formula field), is it reasonable to assume that Salesforce is smart enough to order its operations such that no deadlocks will occur?
Message Edited by glorge on 11-18-2008 06:39 PM
glorge,
Could you please let me know what you found out please?
We are experiencing the same issue...
Thanks a lot!
In our case I can confirm that it was a combination of multi-threaded upserting and roll-up summaries. (In my third post, where I said I had turned off multi-threading, it turns out there was a bug on our side that was allowing multiple threads to access the API).
For example, say you have three records - A, B, and C - where B and C are "details" and A is the "master". Furthermore, assume that B and C "roll up" into A via a roll-up summary. What I've found is that:
I hope this information is helpful.
-Greg
I've found this thread very useful but didn't see an answer to the edit mode question.
Anyone know if having the record open in "edit" mode will lock the record or is it only when the update is actually executed, i.e., when they hit save?
Apologies for reviving a dead thread but just in case someone searches this, I found I reduced the amount of record locking errors if I sorted the 'detail' records by the master unique key. I also offloaded transformations from a trigger to a ETL program. I used Talend Open Source (www.talend.com) and it works pretty well as a code generation ETL program. I'm not sure this could be used for roll-up summaries on the master. I also use the Apex Data Loader CLI for batch processing serial upserts over night. Hope this helps...
Thanks to everyone who has contributed to this thread. I have to say this may be one of the most informative/useful posts I have seen on the force discussion boards. This information has not helped resolve my issue, but after reading the thread I actually have an idea about what is causing this error in my org.
Thank You!!!
Hi There
I encountered the same issue "unable to obtain exclusive access to this record" when I tried to load a set of data into SF.
and got the same issues hours later.
When I ignored that set of data and load a new set, the issue was gone..
For some reason one or more record in that set was locked. How can I find out what and why that record(s) is locked?
Our workaround was to change the relationship to allow the reference to be nulled, but then set up a trigger that disallows deletion of the related object when there are still objects referencing it.