function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GlennAtAppirioGlennAtAppirio 

UNABLE_TO_LOCK_ROW error during deployment - SFDC bug

I'm posting this in the hopes of helping "the next guy" that hits this.  

 

Our ant-based deployments, which had been going flawlessly for months, suddenly started failing, with lots of UNABLE_TO_LOCK_ROW errors in the logs from our various Apex test methods.  The same exact test methods passed when executed from "Run All Tests" in the UI.  We tried deploying with Eclipse and Change Sets, but got the same UNABLE_TO_LOCK_ROW errors.

 

The lines of code that were failing were all record inserts for certain objects.  We realized that if we removed those objects from our package.xml, we could complete the deployment without the errors.  However, we are making lots of object-level changes (new fields, etc), so this was a bad long-term solution.

 

After much troubleshooting, SFDC Tech Support finally found the root cause.  It turns out that if you modify the format of an auto-number field - say, change the name from "C-{0000}" to "CDM-{0000}" - subsequent deployment of that object will fail if any test methods insert records of that object.

 

Ouch.  Ugly, bad bug.  But once we knew the cause, we matched up all auto-number field formats in our source & destination orgs, and then re-ran the full ant script (with all objects) again, and the deployment was successful.

 

Hopefully SFDC will fix this odd bug quickly.  But in the meantime, if you get UNABLE_TO_LOCK_ROW" errors during deployment, check your auto-number field formats!

Volker_factory42Volker_factory42

I also hope to get a solution for this problem. I have the same issues

http://boards.developerforce.com/t5/Apex-Code-Development/UNABLE-TO-LOCK-ROW/m-p/208794#M36878

KruviKruvi

I had the same problem and aligning the Auto Number field solved it.

 

Thanks for the advice

 

 

admintrmpadmintrmp

Hi, I am getting the same problem and would like to fix this - however I can't update our customers org automatically since the errors occur on installation of the managed package. What am I supposed to do about this since I can only update the Name field after installation?

Manu ErwinManu Erwin

Thank you - just had the same problem and because of *this* post am able to keep deploying.

Mike_M_2Mike_M_2

 

Thank you VERY much for posting that. Extremely important. 

sorenkrabbe1sorenkrabbe1

Thank you!!... Extremely valuable post!