You need to sign in to do that
Don't have an account?
Jennifer Molske
Batch Apex Job fails with REQUEST_RUNNING_TOO_LONG
Hello,
I've got a simple BatchApex-Cronjob which should delete all objects of a custom objects.
The cronjob gets executed every night and always fails with a REQUEST_RUNNING_TOO_LONG exception. So the problem is my soql query, right? I've already added the LIMIT 20000 condition hoping that it will fix the problem. But nope.
If I execute the query in the developer console I also get a "No response from server" message.
Any guesses how I can solve this problem? Thanks in advance ;-)
I've got a simple BatchApex-Cronjob which should delete all objects of a custom objects.
global class BatchDeleteWorklogsJob implements Database.Batchable<sObject>, Schedulable { global final String query = 'SELECT Id FROM Issue_Worklog__c LIMIT 20000'; global void execute(SchedulableContext sc) { deleteWorklogs(); } global void deleteWorklogs() { BatchDeleteWorklogsJob deleteJob = new BatchDeleteWorklogsJob(); ID batchprocessid = Database.executeBatch(deleteJob); } global Database.QueryLocator start(Database.BatchableContext BC){ return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<sObject> scope){ delete scope; Database.emptyRecycleBin(scope); } global void finish(Database.BatchableContext BC){ if(!Test.isRunningTest()) { List<Issue_Worklog__c> liste = [SELECT Id FROM Issue_Worklog__c LIMIT 20000]; if(liste.size() > 0) { //Die Liste ist noch nicht leer, daher erneut ausfuehren deleteWorklogs(); } else { //wenn alle Worklogs geloescht sind, dann loesche anschließend die Issues BatchDeleteIssuesJob.deleteIssues(); } } } }
The cronjob gets executed every night and always fails with a REQUEST_RUNNING_TOO_LONG exception. So the problem is my soql query, right? I've already added the LIMIT 20000 condition hoping that it will fix the problem. But nope.
If I execute the query in the developer console I also get a "No response from server" message.
Any guesses how I can solve this problem? Thanks in advance ;-)
Try this.....
global class BatchDeleteWorklogsJob implements Database.Batchable<sObject>, Schedulable {
global final String query = 'SELECT Id FROM Issue_Worklog__c LIMIT 20000';
global void execute( SchedulableContext sc )
{
Database.executeBatch(new BatchDeleteWorklogsJob(), 100);
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope){
delete scope;
Database.emptyRecycleBin(scope);
}
global void finish(Database.BatchableContext BC){
if(!Test.isRunningTest()) {
List<Issue_Worklog__c> liste = [SELECT Id FROM Issue_Worklog__c LIMIT 20000];
if(liste.size() > 0) {
//Die Liste ist noch nicht leer, daher erneut ausfuehren
deleteWorklogs();
}
else {
//wenn alle Worklogs geloescht sind, dann loesche anschließend die Issues
BatchDeleteIssuesJob.deleteIssues();
}
}
}
}