error

Too many batch jobs in the Apex flex queue

What does this error mean?

Salesforce allows up to 100 batch jobs in the Apex Flex Queue at a time. If your system attempts to add another batch job when the queue is already full, Salesforce throws this error.

The Apex Flex Queue manages batch jobs waiting to be processed. Jobs are executed in order as processing capacity becomes available.

Common Causes

1. Scheduling too many batch jobs

Automated processes may schedule batch jobs too frequently.

2. Recursive batch job execution

Batch jobs that trigger additional batch jobs can fill the queue quickly.

3. Failed or stuck jobs

Some jobs may remain in the queue without completing.

4. Multiple integrations triggering batch jobs

External systems may start batch processes simultaneously.

How to Fix It

Solution 1 — Check existing batch jobs


Setup → Apex Jobs

Review running and queued batch jobs and remove unnecessary ones.

Solution 2 — Use job status checks

Apex

Integer runningJobs = [
    SELECT COUNT()
    FROM AsyncApexJob
    WHERE JobType = 'BatchApex'
    AND Status IN ('Processing','Queued')
];

if(runningJobs < 100){
    Database.executeBatch(new MyBatchClass());
}

Solution 3 — Stagger batch job execution

Use scheduled jobs or platform events to space out batch processing.

Solution 4 — Consolidate batch jobs

Instead of running multiple batch jobs, combine logic into fewer jobs processing larger datasets.

lightbulb

Pro Tip: Monitor AsyncApexJob records to track batch job usage and avoid filling the Apex Flex Queue.