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
Dinesh MultaniDinesh Multani 

Apex Job stuck in Holding status until next batch

We have created one Batchable class at our client org. For now we have no code in our batchable class but just select query. we are facing an Issue that last Apex JOB remains in “Holding” status until we Abort OR new JOB started i.e. As soon as new job started the previous scheduled JOB with “Holding” status get completed and new JOB get stuck in “Holding” . 

Any help will be greatly apprecaited. 
Best Answer chosen by Dinesh Multani
Dinesh MultaniDinesh Multani
We had contacted Salesforce to solve this issue. It seems that something happened to that particular org.

All Answers

Abhishek BansalAbhishek Bansal
Hi Nitin,

Any jobs that are submitted for execution but aren’t processed immediately by the system are in holding status and are placed in a separate queue (the Apex flex queue). Up to 100 batch jobs can be in the holding status. When system resources become available, the system picks up jobs from the Apex flex queue and moves them to the batch job queue. The status of these moved jobs changes from Holding to Queued. Queued jobs get executed when the system is ready to process new jobs.
Without administrator intervention, jobs are processed first-in first-out—in the order in which they’re submitted. Administrators can modify the order of jobs that are held in the Apex flex queue to control when they get processed by the system. For example, you can move a batch job up to the first position in the holding queue so that it is the first job that gets processed when the system fetches the next held job from the flex queue.

Thanks,
Abhishek Bansal.
Dinesh MultaniDinesh Multani
Thanks for your relpy.

As mentioned earlier, Our JOB keeps HOLDING status until next JOB comes. We have scheduled JOBS for every five minutes and JOB would be in HOLDING status only for five minutes.  Also, we have very less code in Batchable class (Just select query to replicate the issue). Everything was working fine till my user was deactivated; then we have scheduled the JOB with active user.
Dinesh MultaniDinesh Multani
We had contacted Salesforce to solve this issue. It seems that something happened to that particular org.
This was selected as the best answer