Description
Our application uses batch apex jobs in order to function properly. These jobs govern record assignment, automated reassignment, and other critical application functions. However, Salesforce only allows up to five batch jobs to run at a time; i.e. to be in a “Processing” status. When this limit is hit, jobs that are submitted are held in the Apex Flex Queue until resources become available to process them. Jobs in the flex queue sit in a “Holding” status until they are released for processing. The flex queue will only hold up to 100 jobs at a time. Once this limit is reached, you will see this error when a batch apex job is submitted.
The first question to investigate when you see this error is which jobs are occupying your processing bandwidth. This can easily be viewed by navigating to Setup > Jobs > Apex Jobs. From there, click “Create New View”, give it a name such as “Running Batch Jobs”, then under Specify Filter Criteria create two filters: Job Type = “Batch Apex”, and Status = “Processing”. This will show your current active batch jobs.
You may see this error occasionally if you have particularly bulky jobs that coincide here and there. In such cases the error can often safely be ignored, as later jobs will usually generate and run just fine. If however you are seeing it consistently, the most common cause is “stuck” jobs, or in other words, jobs in a “Processing” status that aren’t actually processing at all. These jobs will usually be unrelated to Kubaru–but can still impact Kubaru performance if not remedied.
Stuck jobs can be identified by looking at the Batches Processed column, which will read 0 no matter how much time has passed. Sometimes these jobs will error out after many hours with a “Salesforce.com internal server error thrown”. It’s possible these jobs are encountering this issue described on Salesforce’s help site.
Resolution
Ultimately the issue behind these jobs will need to be identified and resolved at a code level by the developer who created them, whether the code was created by one of your own developers or is part of a third-party managed package. Please reach out to us at support@kubaru.io for assistance.
As a temporary workaround, while the problematic code is being fixed, you can monitor and abort these stuck jobs to ensure they don’t prevent other jobs from running.