Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Salesforce stuck in Organization Administration Locked state after using Apex Test Execution

Tags:

salesforce

I used the Apex Test Execution screen to run all the test cases in a sandbox org.

Several of the test cases passed and then progress appeared to hang on one test case which was previously working.

I then used the Abort button to try and cancel the test execution which appeared to work.

Now any subsequent attempts to run tests never progress past the Queued state.

ApexTestQueueItem stuck in Queued State

Selecting an individual apex class and using the synchronous Run Test button results in the following error message:

Organization Administration Locked

The changes you requested require salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for the previous action to finish, then try again later.

Trying to save changes to an Apex Class from Eclipse gives the error:

  • Save error: Unable to perform save on all files: The changes you requested require > salesforce.com to temporarily lock your organization's administration setup. However, the administration setup has already been locked by another change. Please wait for > the previous action to finish, then try again later. (ALREADY_IN_PROCESS)

If I query the ApexTestQueueItem table there appear to be 3 test cases stuck with the Processing status.

ApexTestQueueItem stuck in Processing

How can I clear out these ApexTestQueueItems from the Processing state? I'm assuming that this will get me past the Organization Administration lock.

I did check the Setup Audit Trail and the only recent changes were from my user to Apex Classes.

like image 626
Daniel Ballinger Avatar asked Feb 28 '12 23:02

Daniel Ballinger


2 Answers

Updated

My support case got escalated to the "Senior Support Team". They did something to my sandbox and advised that it is a known issue and to only run test cases for one class at a time via the Apex Class UI (E.g. https://xyz.salesforce.com/01pL00000000001).

I should not run the test cases via:

  • The Apex Test Execution UI
  • Manually creating ApexTestQueueItem records
  • Apex Classes - [Run All Tests]

I'm assuming that Eclipse is OK at the moment for individual test cases as it isn't async in nature.

I'd like to be able to tell you what exactly they did to my problem sandbox orgs but I'm not sure at the moment. Hopefully a parallel question on the developerforce forum will produce some answers - Using Apex Test Execution results in a "Organization Administration Locked" that doesn't clear

Some interesting info from Twitter:

"...been working on it all day. Hope to have the fix out next wk." - Rich Unger

"@rich_unger great to hear, thanks for update, any short term workaround? if not, I'll move my code to another org until then" - Michael Gallagher. "@mjgallag24 workaround is to not use async testing" - Rich Unger

So to answer my own question of "How can I clear out these ApexTestQueueItems from the Processing state?"

Answer: You can't currently if you are experiencing the "known issue". The only option is to raise a support case and wait for Salesforce to clear it.


I've tried the following anonymous apex to clear the apex test cases out of the processing queue:

List<ApexTestQueueItem> items = [Select Id,ApexClassId,Status,ExtendedStatus,ParentJobId from ApexTestQueueItem where Status != 'Completed'];
for(ApexTestQueueItem atqi : items) {
    atqi.Status = 'ABORTED';
}
update items;

This doesn't seem to have the desired result as on a subsequent SOQL query to ApexTestQueueItem the Status column remains unchanged.

I went looking for the Apex job under [Administration Setup > Monitoring > Apex Jobs] but none of the records where JobType=TestRequest appeared.

Next I tried aborting the job using anonymous apex:

System.abortJob('707L0000000FgZIIA0');

The AsyncApexJob changed Status to 'Aborted'.

like image 68
Daniel Ballinger Avatar answered Oct 14 '22 23:10

Daniel Ballinger


In one of my orgs it's unlocked after around 16 hours, I was able to avoid getting it locked again by running my test classes one at a time, but not through the Apex Text Execution page, I am either doing did it through the IDE or Apex Class Page in the UI

like image 39
manubkk Avatar answered Oct 15 '22 01:10

manubkk