[SalesForce] Scheduled Batch Apex Failing Mysteriously

A batch apex class which is scheduled to run daily has been failing lately. It either shows Completed, with 0 total batches (which isn't right if it really ran as expected), or it shows Failed, with an odd error message (just "job xxx failed"). However, if I run it manually (via dev console, using same batch size) it completes as expected.

Here's the apex jobs listing:

enter image description here

The two recent runs showing 7 batches processed are the ones I launched manually. All the others (starting at 6 am) are the failed scheduled runs.

Interestingly, there is also a job shown from much earlier in the year, showing status = Queued. Could that be interfering w/ the scheduled runs somehow? (ignore this)

Any advice on what I should look into here?

Best Answer

The view of the screen shot you present is filtered to only show one job. I think you should look at all the jobs that are being run: you might find some correlation between the failures and runs of other jobs that are interfering with this job.

I can't offer anything on the "Failed" ones with nothing helpful in the detail... Open a case with Salesforce?

"Queued" means:

Job is awaiting execution.

whereas "Preparing" means:

The start method of the job has been invoked. This status might last a few minutes depending on the size of the batch of records.

which suggests to me that the stuck job shouldn't be the cause of the problem in the other jobs.

I presume the cases where there was a second run in one day were manual repeats because of the zero records processed by the scheduled job?