0

Here i have issue regarding Apex Job.i have completed the Apex batch job but total batches are 0.

Should I be concerned here why that the batch controller is showing “0” here?

here is the screenshot....please give me answer ASAP....

enter image description here

2
  • 1
    Are you sure your query returned records? Check your logs, there may have been an exception.
    – Mike Chale
    Jun 3, 2014 at 2:55
  • thanks for your prompt reply here i check log that batch job returns records and there would not any exception.so here what is the next step so i can solve this kind of problem.....
    – Vivek113
    Jun 3, 2014 at 4:37

2 Answers 2

2

Yes you should be concerned. From my experience that probably means that you're getting timeout exception at one point of batch execution. In such case not all records are processed and finish method of batch is not called.

I've been struggling with timeout exceptions in batch for long time and batch can end in various statuses:

  • Aborted
  • Completed with Batches Processed = 0
  • or even Completed with Total Batches = 0 (like in your case)

Completed with Batches Processed = 0 doesn't even mean that 0 batches were processed. If you would watch the execution on apex jobs screen live you could see that some batches are processed and then when timeout occurs sometimes this number goes back to 0 and entire batch job gets status Completed.

2
  • 1
    Wouldn't a timeout limit throw an exception?
    – Mike Chale
    Jun 4, 2014 at 18:38
  • I'd say you can't catch this type of exceptions. Just like you can't catch an exception when exceeding Salesforce Governor Limits. Transaction is just terminated.
    – neff
    Jun 5, 2014 at 15:49
1

As per the documentation, you have to pass the records to the Execute method. This passing is done using Start method, if the Start method doesn't returns a Database.QueryLocator object or an iterable that contains the records or objects passed to the job, then execute is never invoked.

To collect the records or objects to pass to the interface method execute, call the start method at the beginning of a batch Apex job. This method returns either a Database.QueryLocator object or an iterable that contains the records or objects passed to the job.

A batch class is counted as a processed one only when the execute method is run after the start method. When the start method doesn't return any records to the execute method then the status is completed but batches processed would be zero.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .