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
Developer BitOrderDeveloper BitOrder 

System.AsyncException: You have exceeded the maximum number (5) of Apex scheduled jobs

Hi All,

I had scheduled around 22 Jobs till last Friday on on SF Org with different schedules. All these 22 jobs were visible in Scheduled Jobs Tab. Starting from this Monday(16th Feb 2015) I'm getting an Error : System.AsyncException: You have exceeded the maximum number (5) of Apex scheduled jobs when I try to schedule the same number of Jobs.
Its allowing only 5 Jobs to be submitted. 

Org might have been upgraded to Spring 2015 over the weekend. As per the Spring 2015 notes, we can use Apex Flex Queues to shcedule upto 100 Apex Jobs. We tried activating the Apex Flex Queue from Critical Updates section, but still the issue persists.

Need advise on what can be done to get the limit back to 100.
Yury BondarauYury Bondarau
Suddenly!

Couple of my colleagues have faced the same problem on different projects / orgs.
Does anybody know a workaround for this surprising limit?
 
Jonathan Bernd 25Jonathan Bernd 25
We got this too. Documentation mentions the limit of batch schedule which is resolved with FlexQueue, but what about this?  Is any limit mentioned in documentation that you know of - apart from 100?
Developer BitOrderDeveloper BitOrder
@Jonathan Bernd 25

As per the below link, the issue should have been resolved with FlexQueue.

https://developer.salesforce.com/releases/release/Spring15/FlexQueue

Not sure if it will get resolved by activating the Apex Flex Queue from Critical Updates or we have to contact SF to activate that.
Yury BondarauYury Bondarau
Hi Developer BitOrder, I could not found where in this article said that activating of Flex Queue will help to increase scheduler (not batch) limit?

Actually, I found Flex Queue among critical updates on my org, but after activation this feature problem still occurs.
User-added image

Guys, I will try find out the reason of this problem through Partner Portal.
Vlad BilykVlad Bilyk
We have the same problem too. Were you able to solve the problem?
Developer BitOrderDeveloper BitOrder
@Vlad Bilyk - No luck yet. Cant reach SF as we do not have a previleged Partner Account. 

@Yury Bondarau- We are worried about the Scheduled Apex Jobs limit. It was 100 till last Friday. It has changed to 5 starting from this Monday.
DevADSDevADS

Read through Apex Flex Queue, It puts batch jobs in holding state, not scheduled jobs.

User-added image

we also started facing this issue since org's have been updated with Spring'15 however we are not facing this issue in sandbox.
sandeep@Salesforcesandeep@Salesforce

The Apex Flex Queue pilot enables you to submit batch jobs beyond the allowed limit of five queued or active jobs. 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.


Links:  https://developer.salesforce.com/blogs/engineering/2014/05/flex-batch-apex-muscles-flexqueue.html
             https://help.salesforce.com/apex/HTViewHelpDoc?id=code_apex_flex_queue.htm&language=en_US
             http://purushottambhaigade.wordpress.com/2014/08/01/apex-flexqueue-muscles-apex-batch-processing/
 
Yury BondarauYury Bondarau
Hello sandeep@Salesforce, the problem described here is about decreasing limit of SCHEDULED jobs from 100 to 5 (NOT a BATCH). Your answer is very interesting by totally inappropriate in this thread.

Do you know any workaround for new limit for SCHEDULED jobs (NOT a BATCH jobs)?
Jonathan Bernd 25Jonathan Bernd 25
sandeep@Salesforce.  There may be some confusion - I think Yury and I are talking about the "scheduled apex class limit" - (per your documentation limit is 100). In the section on your documentation, it's right under the limits for batch jobs
Jonathan Bernd 25Jonathan Bernd 25
Another point. It appears this bug is not present in sandboxes (at least we haven't found it yet), but is present in our partner orgs.
 
Richard CheethamRichard Cheetham
Yes, as per the current documentation here http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm

Scheduled Apex Docs

- you can have up to 100 Scheduled Apex Jobs, scheduled for execution at their specified time as per a cron expression.
This is broken post Spring'15; even though you are entitled to set up more jobs if you have fewer than 100, you've lost the ability to schedule any new ones.  If you delete an existing job, you can't put it back either.  I think this is going to have a lot of impact on time-sensitive customer integrations/processes so I hope the functionality can be restored asap.

Enabling the Flex Queue critical update doesn't fix it.

Appreciate your help on this sandeep@salesforce
Kevan MoothienKevan Moothien
This issue came along with the upgrade to Spring 15 release. I have already logged a case for this and Salesforce support are investigating on it.
Apex Flex Queue is of no help if you need to have your batches to run at different time. 
kaplanjoshkaplanjosh
What is the scenario where you need to run so many scheduled jobs in a development environment?
Developer BitOrderDeveloper BitOrder
@Kevan Moothien

Thanks for the Update.
Kevan MoothienKevan Moothien
@kaplanjosh 
we have got several batch which need to be run hourly, some every 4 hours. And we even have batches which schedules other batches. These batches update records that can later be used in other batches.

 
kaplanjoshkaplanjosh
Why do you have batches that need to run hourly in a development environment? What are these jobs doing?
Kevan MoothienKevan Moothien
We are in ISV mode. Which is still under testing, so we need to ensure everything is working fine.
My problem is that we can't schedule more than 5 batches and it will have an impact if this problem goes on production environments.
kaplanjoshkaplanjosh
Your use case is that you want to test the operation of the Salesforce cron scheduler. I don't think that should be an ISV responsibility! If you can successfully schedule 1 job, and you can successfully schedule 5 jobs, do you need to test 10, 15, 25, etc.? 

On top of that, you can't test how this would look in production without a priori knowledge of how many jobs will be already scheduled by your worst-case-scenario subscriber.
Kevan MoothienKevan Moothien
I use to have more than 20 batches in my scheduled job. NOT maximum of 5. I am not trying to test the operation of the Salesforce cron scheduler. There is either a bug or a new limit in salesforce which by the way it seems that nobody is aware of it. Not even salesforce support technician. They are still investigating on the issue. This issue is happenning on every environment I try to schedule more than 5 batches. 
Developer BitOrderDeveloper BitOrder
In our case, we have to schedule a Batch to run every 5 minutes. We can schedule a batch to run once every hour using cron. So we need to have 12 Scheduled Batches which will run every 5th, 10th, 15th, 20th ...... MInutes.We could schedule all 12 jobs before the Spring 15 upgrade. Now we cannot schedule more than 5.
Yury BondarauYury Bondarau
Guys, is this problem exist on Production orgs? Or only on Development environments (DE orgs)?
Kevan MoothienKevan Moothien
I have been able to reproduce this error on DE orgs and Sandboxes. On Enterprise edition org (production) it is working fine.
kaplanjoshkaplanjosh
why do you need to schedule something to run every 5 minutes in your development environment? Can't you just schedule it to run every 20 minutes?
René PienkoßRené Pienkoß
We have this issue in our Trialforce orgs (TMO and TSO), that are used to create Free Trial Orgs for customers to test our application. We need to have more than 10 Apex Jobs scheduled in our application. That never was a problem before Spring '15. So that new limit would mean for us, that we are not able to provide full functionality of our application in Trial Orgs. Later the Trial Orgs becomes Professional Editions, so we have to schedule the Apex Jobs always manually afterwards.
Developer BitOrderDeveloper BitOrder
@kaplanjosh - It is not necessary that we schedule it every 5 minutes. We can shcedule it every 20 mins or even 1 hour. But we just wanted to replicate the scenario for our app as it will be in EE Org. It was suddenly broken. Do you mean to say that in Production EE org this is still working? 
Jonathan Bernd 25Jonathan Bernd 25
Just some more info. 1) For us we found out Thursday the issue was across the board in production and dev orgs (at least in the editions we tried), but not in sandboxes spun off any of those orgs. Spoke with a developer at SF on Friday and gave them an example and login access to a production EE org we made where it was happening and a sandbox from that org where it wasn't. They were looking at it Friday and think it's likely a bug, but will get back to me.
Richard CheethamRichard Cheetham
This issue affected an Enterprise Edition demo/test environment we had created from the Partner Portal.  Thanks to @Abhishek at Salesforce who responded to my case, the news is that this was due to a new limit of 5 imposed on Trial/Free Orgs from the time of the release.  Due to the impact caused by the change, that limitation will be removed in 1st week of March and we should see the ability to schedule up to 100 Apex Jobs restored in all types of Orgs where it was possible before.  Interested to know of any production Orgs affected as we have held back from a customer go-live while seeking updates on this.
Yury BondarauYury Bondarau
Thank you Richard - this is very helpful!
Jonathan Bernd 25Jonathan Bernd 25
Thanks Richard. I also get an email from SF this morning. Seems like something was released by accident that they thought they had removed. They told me that if needed in the interim (before the fix) they may be able to help/fix on an org by org basis if cases are made.
Wonder if this signals that they may be thinking of this limit in roadmap.
Yury BondarauYury Bondarau
Guys, Salesforce support respond to my ticket yesterday and they said that this is a known issue:
https://success.salesforce.com/issues_view?id=a1p300000008Y2RAAU

Please click 'This issue affects me' in case you would like to be notified about the problem status.