Today, while working on one of class, when I tried to save my changes I got following error:-
Error: Compile Error: Schedulable class has jobs pending or in progress at line 5 column 21
I thought, its coming because there may be some job is running or scheduled. However, when I checked Setup >> Build >> Jobs >> Scheduled Jobs, I couldn't find any scheduled job. Just to be sure that there is not any apex job in running status I checked Setup >> Build >> Jobs >> Apex Jobs. And there were not any job in running status.
Just to be clear, Apex Jobs were listed in descending order of Submitted Date. I just checked first few of Apex Jobs. They were either in Aborted or Completed status.
I was wondering what's wrong. After further analysis, I decided to check Setup >> Build >> Jobs >> Apex Jobs in more detail. After scanning status of all Apex Jobs, I found one job which was still in 'Queued' status. And it's Submitted Date was 15 days older. Something might have went wrong and this job got stuck in queue only.
Next question was, how to get rid of this stuck job. I thought of deleting this job by deleting this record from 'AsyncApexJob' object. However, we can't update or delete record from 'AsyncApexJob'.
The other option I found after further exploration, is that there is a method 'System.abortJob()', which change the status of Apex Job from 'Queued' to 'Aborted'.
We as developer, can use 'Developer Console' to get rid of stuck job using above method.
Error: Compile Error: Schedulable class has jobs pending or in progress at line 5 column 21
I thought, its coming because there may be some job is running or scheduled. However, when I checked Setup >> Build >> Jobs >> Scheduled Jobs, I couldn't find any scheduled job. Just to be sure that there is not any apex job in running status I checked Setup >> Build >> Jobs >> Apex Jobs. And there were not any job in running status.
Just to be clear, Apex Jobs were listed in descending order of Submitted Date. I just checked first few of Apex Jobs. They were either in Aborted or Completed status.
I was wondering what's wrong. After further analysis, I decided to check Setup >> Build >> Jobs >> Apex Jobs in more detail. After scanning status of all Apex Jobs, I found one job which was still in 'Queued' status. And it's Submitted Date was 15 days older. Something might have went wrong and this job got stuck in queue only.
Next question was, how to get rid of this stuck job. I thought of deleting this job by deleting this record from 'AsyncApexJob' object. However, we can't update or delete record from 'AsyncApexJob'.
The other option I found after further exploration, is that there is a method 'System.abortJob()', which change the status of Apex Job from 'Queued' to 'Aborted'.
We as developer, can use 'Developer Console' to get rid of stuck job using above method.
Comments
Post a Comment