We have a batch that is running queueable inside batch execute. And we are testing this framework with volume data to know its limits. To give an example, if I test it using 1000 records with 1 scope size for batch then it will run 1000 batches and 1000 queueables. And likewise, if I increase scope size to 10 then it will run 100 batches and 100 queueables. Now we tested it with 150K records with 1 scope size and it failed as expected (300K asyncapex required while we get only 250K) with below error- enter image description here This failure also caused our complete process to fail which was expected.

On another org, we ran this with another flavor (P.S. 1) with the same number of records and the same scope size and got the process as completed because the apex job did not fail ( I don't know why). Below screen showing only apex jobs of type batch which ran on this org enter image description here

On another org, we ran a mix flavor- two jobs in the chain (chained one after other using queueable chaining). This time we used 120K records 1 scope size. So we needed 120K + 120K for the first job and same 120K + 120K for next job. And it was bound to fail on second job so it did. But this time we got another type of error. enter image description here As we can see, it finished first job and consumed 240K async limit. Now next process started and failed instantly because it needed 120K limit (P.S. 2 below) which was not available.

Can anyone explain the different errors and statuses we are getting - null vs Rate Limiting vs job (ID of job) failed (though it's status is completed).

P.S. 1- The another flavor is that first test creates few extra custom object log records while second test is of simple type which omits the creation of custom log objects. The rest of the things are same for both flavors. In third test, we mixed both flavors. And hence the 60 counts in third screenshot (120K/2000) i.e. we ran another batch with 2000 scope to create those log records upfront before running the next job in the chain.

P.S. 2- From a series of tests, we are able to establish the fact that salesforce doesn't know what we are doing inside batch execute (we are creating queueable in batch execute). But it calculates the limit it will need to complete that batch and checks if that limit is available. If not, it fails instantly. And in the process of checking this limit, salesforce does not consider any chaining (like we had for third case) or queueables from batch execute etc, just plain batch executes.

P.S. 3- All three tests are on three different DE orgs.

P.S. 4- I checked SFDC focs and ended up with nothing. RateLimit exception is thrown from Chatter while we are not doing any chatter stuff-

  • You get 250k async jobs or 200 * user licences, whichever is greater, so that may explain why the job succeeded in the second instance. – barrick Jul 24 at 22:14
  • And this is something of a speculation, but is there a chance that in example 3, there was just no space left in the limits to process that number of batches at the start, whereas in example 1, there was initially but other items were added to the async queue during execution which made it run out of limit half way through? Although it could be asked why the platform would refuse to start a job if there's a chance the rolling window means that there may become sufficient capacity as it runs. – barrick Jul 24 at 22:17
  • As it was DE org so the limit was just 250K. And i can assure you that no one touched these orgs during the execution so no operation was taking the limit other than the process itself. I support you point that platform should at least start the job even if the limit is not available upfront but our series of tests have shown otherwise. – love gupta Jul 25 at 11:31
  • Yes, that doesn't shine any more light on what's going on. It might be one to log with SFDC support. In terms of resolution, I assume that it's perfectly reasonable for you to have a batch size > 1, and that this is just an interesting technical observation? – barrick Jul 27 at 22:28
  • Could you provide the basic structure of the code or pseudo code without the logic inside the methods? Basically, a code showing the class and methods (without the actual functional code inside them). This error could have been due to the way Salesforce calculates the limits or for a variety of other reasons. Hard to tell just by looking at your question details. – arut Jul 31 at 13:28

Your Answer

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

Browse other questions tagged or ask your own question.