Loading

'Holding' status on Batch Jobs

Publiseringsdato: Jul 5, 2023
Beskrivelse
Batch Jobs not executing and all the submitted jobs are turning into "Holding" Status
Løsning
If Batch jobs are stuck in Queue and are not executing in the expected time.  You will need to first execute the below query:

SELECT Id, CreatedDate FROM AsyncApexJob WHERE JobType='ApexToken' AND Status = 'Queued' 

If the above query returns any records then please log a ticket with Salesforce Support.

If there are no records returned in the above query then follow the below steps:
1. Login to Workbench
2. On right corner, it will be showing your name and API version. Click on the link.
3. There you will find change API version, change it to 31
4. Go to Utilities | Apex Execute and run the command below.
for ( AsyncApexJob aJob : [ Select id ,Status from AsyncApexJob where Status = 'Queued' or Status='holding'] ) 
{ 
System.AbortJob(aJob.Id); 
}

5. Now all the existing old jobs will be deleted.
6. Now re-schedule the jobs.


Note: Without changing API version if you execute the below query:
 
for ( AsyncApexJob aJob : [ Select id ,Status from AsyncApexJob where Status = 'Queued' or Status='holding'] ) 
{ 
System.AbortJob(aJob.Id); 
}

You might see error:

System.StringException: You can't abort scheduled apex jobs by calling System.abortjob() with an AsyncApexJob ID. You must call System.abortjob with the parent CronTrigger ID.

Change the API version to 31.0 and execute the code specified above.
Knowledge-artikkelnummer

000381767

 
Laster
Salesforce Help | Article