3

I have written a Batch Class which will Map Contact Object to lead Object. I have 6,000,000 which will be Mapped to Lead (like i am creating Lead using Contact Details). But when I am running the Batch with Size 1 it is giving me the Following Error:

AsyncApexExecutions Limit exceeded.

How can I resolve the above exception?

4

A possible cause is you are hitting governor limits for Async transactions

Per the doc, the limit is:

250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater

So, if you had 100 user seats, your limit is 250,000 - 2 = 249,998 execute() invocations.

(-2 because the start() and finish() consume one async transaction each)

If you had 10,000 user seats, your limit is 1,999,998 execute() invocations.

With 6,000,000 records processed with batch size = 1, you would need a user org of 30,001 seats.

And, this assumes that during the 24 hour period, no other async job consumes async resources.

Suggested solution is to make the batch size bigger (like the default of 200).

An alternative solution would be to export all the Contacts to Excel, then use the Bulk API option of Data Loader to create Leads.

  • Can you just clarify why -2? Might also be worth mentioning the minimum viable batch size. (I think it's just 24?) – Adrian Larson Jul 18 '16 at 14:26
  • 1
    @AdrianLarson - DONE (I put the -2 in because I knew one of you guys would jump on me for the calculations re: start and finish if I omitted it. :-). I'm not familiar with any minimum viable batch size. – cropredy Jul 18 '16 at 14:41
  • In re: minimum viable batch size, I mean that it has to be more than 1, but you don't have to bump it all the way up to 200, necessarily. There is some minimum size that will work. with 6M records, if you max out at 250K, then you need to set it at least to 24. If the numbers were exact, I guess you'd need 25 because of the start and finish calls). – Adrian Larson Jul 18 '16 at 14:50
  • 1
    @AdrianLarson - ah, I thought you meant some other SFDC feature. If OP had 10,000 user seats, then MVBS = 4. But main point is batch size of 1 is problematic and I'll trust OP to use basic arithmetic to decide what to do next. – cropredy Jul 18 '16 at 15:27
  • In my experience 10k seats is a pretty big org. I guess it depends on how many communities you have set up... – Adrian Larson Jul 18 '16 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.