function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Failed (Asynchronous) Apex Job

Is there any way to trap / report errors from failed Asynchronous Apex Jobs? I believe that my method is hitting the 10,000 row query governor limit, or a DML update limit, despite putting limitations on the SOQL query (using LIMIT) and batching updates using the recommended batching methods.

If I set the SOQL LIMIT to 4000-5000 records it seems to complete successfully, but if it tries to handle between 5000 and <10,000 rows it fails. As well, the job actually appears to be successful, it updates all the data it was expected to up to the LIMIT, and yet I don't get any email or error as to why the job failed but it says Status=Failed in the Apex Jobs view.

Any thoughts on how I can get the error that's causing the Apex job to fail?


Message Edited by JustinC on 11-20-2008 01:33 PM
Here's some more information:

The script takes about 4-5 minutes to complete.

The method is doing exactly what it's supposed to be doing, and working well, except the Apex Job still lists the status as Failed.

The Debug Logs don't seem to show any errors and I'm not getting "ApexApplication" email notifications that there was a problem with the script.

At the end of the method I added an email that would send me a printout of each of the governor limits to see if any were being violated - doesn't look like it.

getAggregateQueries(): 0
getLimitAggregateQueries(): 300
getCallouts(): 0
getLimitCallouts(): 10
getDMLRows(): 9000
getLimitDMLRows(): 10000
getDMLStatements(): 45
getLimitDMLStatements(): 100
getEmailInvocations(): 1
getLimitEmailInvocations(): 10
getFieldsDescribes(): 0
getLimitFieldsDescribes(): 10
getFindSimilarCalls(): 0
getLimitFindSimilarCalls(): 10
getFutureCalls(): 0
getLimitFutureCalls(): 10
getHeapSize(): 13026
getLimitHeapSize(): 1000000
getQueries(): 47
getLimitQueries(): 100
getPicklistDescribes(): 0
getLimitPicklistDescribes(): 10
getQueryRows(): 9046
getLimitQueryRows(): 10000
getRunAs(): 0
getLimitRunAs(): 0
getSavepointRollbacks(): 0
getLimitSavepointRollbacks(): 20
getSavepoints(): 0
getLimitSavepoints(): 5
getScriptStatements(): 99607
getLimitScriptStatements(): 200000
getSoslQueries(): 0
getLimitSoslQueries(): 20
Any ideas? I'm stumped why the job lists Status=Failed even though it seems to be working well.


Not sure if you still need an answer, but why not check the Apex jobs log under Setup->Monitoring->Apex Jobs