AsyncApexExecutions Limit exceeded error for apex batch

I am getting “AsyncApexExecutions Limit Exception” in below code –

Can anyone explain the issue? i have been getting more than 1 lakh records in start method using queryLocator but didn’t get this exception. So what is wrong in this code

global class SyncCalendarsUpdates implements Database.Batchable<sObject>, Database.AllowsCallouts {
    global Database.QueryLocator start(Database.BatchableContext BC) {
        String query = 'SELECT Id, Event_ID__c, Description__c, Event_Owner__r.Id, Subject__c, Start_Datetime__c, End_Datetime__c, Click_Key__c FROM Updated_Event__c';
        return Database.getQueryLocator(query);

    global void execute(Database.BatchableContext BC, List<Updated_Event__c> scope) {


    global void finish(Database.BatchableContext BC) { }


‘AsyncApexExecutions Limit Exception’ means you are hitting an org wide 24 hour rolling limit on asynchronous Apex.
“The maximum number of asynchronous Apex method executions (batch Apex, future methods, Queueable Apex, and scheduled Apex) per a 24-hour period: 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater”

Adding the result of these two queries should help you see where you are at:

Integer nonBatchAsyncApexJobs = [SELECT count() FROM AsyncApexJob WHERE JobType != 'BatchApexWorker' AND JobType != 'BatchApex' AND CreatedDate >=];

AggregateResult[] ar = [SELECT SUM(JobItemsProcessed) FROM AsyncApexJob WHERE JobType = 'BatchApex' AND CreatedDate >=];

Integer batchJobItemsProcessed = Integer.valueOf(ar[0].get('expr0'));

Integer total = nonBatchAsyncApexJobs + batchJobItemsProcessed;

System.debug('total: ' + total);

The second query can be especially important because JobItemsProcessed represents the number of batches processed in a BatchApex type AsyncApexJob. Each batch is counted towards the limit and this can add up quickly depending on the run frequency and records processed per batch.

Source : Link , Question Author : Pramod Kumar , Answer Author : Craig Johnson

Leave a Comment