13

I'm facing the "ghost" job issue in an organization (thankfully is a sandbox). I had a class scheduled to run in a daily basis, and it was working fine, until I accidentally scheduled it again (2 jobs for the same class).

It ran, and scheduled itself again (the scheduling part is in the code, I didn't use SF's UI to set it up). After that I went to see the scheduled jobs, and excluded both of them.

After this whole story, I tried to edit something in the class, and Salesforce won't allow me to because supposedly the class has jobs pending or queued. When visiting the Apex Jobs page, indeed, there is a job that is marked as 'queued'. But I can't seem to delete it. When I run System.abortJob('thejobIdhere') Salesforce throws me an error:

System.StringException: You can't abort scheduled apex jobs by calling
system.abortjob with an AsyncApexJob ID. You must call system.abortjob
with the parent CronTrigger ID.

But that CronTrigger Id doesn't exist in the system anymore, so I can't delete the job.

I have seen an issue like that at Salesforce Dev Community (https://developer.salesforce.com/forums/?id=906F0000000BOuqIAG), an answer to a similar question in here (How to delete AsyncApexJob with Queued status - doesn't work for me), also there is a fixed issue (https://success.salesforce.com/issues_view?id=a1p30000000STwPAAW), but I am facing the issue.

What can I do to exclude this queued job, so I can edit my class?

  • 1
    Try running the System.abortJob using workbench and API version 32.0 – Sreenivas Oct 19 '17 at 16:57
21

EXCEPTION: System.StringException: You can't abort scheduled apex jobs by calling system.abortjob with an AsyncApexJob ID.

You must call system.abortjob with the parent CronTrigger ID.

I tried same in workbench with lowed api version then it worked. I was able to delete 2 jobs in API version 32. Follow these steps to run this statement:

  1. login to "https://workbench.developerforce.com/login.php"
  2. On right corner, it will be showing your name and API version. Click on that link
  3. There you will find change API version, change it to 32
  4. Go to Utilities >> Apex Execute There run this command with job Id

I believe this would help you. Please let me know if you have any other questions, I would love to help you in that as well.

  • This is a bug at salesforce side and version 32 or lower work – Avijit Chakraborty Jun 18 '17 at 14:16
  • This should be marked as correct answer ! – Nepz Solutions Oct 9 '18 at 8:38
5

Turns out that I had to open a case with Salesforce to solve this. After more than 10 days, and two escalations, they didn't solve the issue. Since I didn't want to waste more time waiting for a miracle, I suggested the exclusion of the entire development environment (the sandbox) and creation of a new one.

This solved the problem, with the downside of erasing every customization I did and didn't push to the production environment. Fortunately I know how to use the Migration Tool, so I could save most of my work.

4

You may have to contact Salesforce support to fix this. They may be able to kill that queued job. We've had a similar issue in the past and we could only solve it by contacting SF.

  • You had to call them, or opening a case was enough? How long it took to get the issue solved? – Renato Oliveira Jan 4 '16 at 14:46
  • 2
    We opened a case. I don't remember the exact timescale, but it was in the order of days, perhaps up to a week. – mkorman Jan 4 '16 at 14:47
  • 1
    You can try to edit your class in a different sandbox (if you have any) and use eclipse to migrate it. As @mkorman said, you need to contact Salesforce to delete the ghost job. Once we escalated to their research and development team to delete a job (event 1st & 2nd level support couldn't delete them). – SL man Jan 4 '16 at 18:00
  • 1
    @SLman Unfortunately we don't have another sandbox to do this test. However, I opened a case with them. They got in touch, I explained the situation (they used a GoToMetting call to record the reproduction steps, awesome!), and the guy who took my issue said they would try to escalate it to the development team. He really emphasized the "try" part, but I think it will work. I'll update this if I succeed. Thank you! :) – Renato Oliveira Jan 4 '16 at 21:04
  • Just a quick update (wow after more than a week!) to this. I've opened a case with Salesforce about this, and they had me to run a batch class to see if it solved the problem (spoiler: it didn't). Now I got the case escalated to the developer support team, and I am waiting for a solution on their side. Yes. 10 days without a solution. Imagine if I had this on the production environment? I'll update this question with an appropriate answer as soon as they solve the problem. If I have to do anything else I'll answer the question. – Renato Oliveira Jan 14 '16 at 19:01
0

You need to perform following:

List<CronTrigger> jobsToAbort = [select Id from CronTrigger where CronJobDetail.JobType = '7']; for (CronTrigger job : jobsToAbort) { System.abortJob(job.Id); }

  • Could you please add more explanation to your answer so that the answer be more clear – Eduard Aug 22 '18 at 7:10
  • Please take some time to read the entire original post. I explicitly say that I do not have the CRON job Id do use System.abortJob. Also, the problem has no other solving (as far as I could tell) other than deleting the sandbox. – Renato Oliveira Aug 22 '18 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.