Total number of Batch jobs decreases during execution. Why that?

A customer of my managed package is experiencing a long running batch job to change the number of total jobs during the run?

  1. How can that be?
  2. Is this an internal optimization at Salesforce?
  3. Or did other users delete records that were queried in start()?
  4. Should I open a case in such cases or can I rely on the status message “finished successfully”?


The root cause is platform bug described in this Known Issue:

In Spring’17 apex batch class (Database.Batchable) doesn’t process all
the batches if batch execute method takes long time to run but within
limits. It stops processing batches after some number of processed
records and finishes unexpectedly. No error is reported, no exception
is thrown.

see Known Issue : Batch Apex job finishes unexpectedly in Spring’17 without processing all specified records

Source : Link , Question Author : Robert Sösemann , Answer Author : Robert Sösemann

Leave a Comment