Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Scheduled job admin page does not correctly reflect running state of abandoned jobs

Found in

EPiServer.CMS.Core 7.0.586.0

Fixed in

EPiServer.CMS.UI 11.4.8

(Or a related package)

Created

Oct 04, 2017

Updated

Jun 08, 2018

Area

CMS UI

State

Closed, Fixed and tested


Description

When running a job, during a stoppage of its work (for instance, using iisreset command), the job is stuck in running state in UI. The next time the job runs, this will be restored.

Reproduction:

  1. Create a custom job. For example:

    public override string Execute()
            {
                string resultMessage = string.Empty;
                int current = 0;
                try
                {
                    for(int i = 0; i< 100000; i++)
                    {
                        current++;
                        
                        //For long running jobs periodically check if stop is signaled and if so stop execution
                        if(_stopSignaled)
                        {
                            System.Threading.Thread.Sleep(60000);
                            return String.Format("Stop of job was called after executed {0} items",current);
                        }
                        //Call OnStatusChanged to periodically notify progress of job for manually started jobs
                        OnStatusChanged(String.Format("Starting execution of {0}", current));
                       }
                    resultMessage = string.Format("Job is completed, {0} has been executed",current);          
                 
                }
                catch(Exception ex)
                {
                    resultMessage = "The job could not be completed";
                }
                return resultMessage;
            }
    
    

  2. Start the job.
  3. Before it finishes, abort it by closing IIS in Task Manager.
  4. Refresh the page.
  5. Locate the job again.

Expected:
The job is not running in the database (IsRunning = 0), and the message doesn't say it is running.

Actual:
The job is not running, but the message says it is, and that problem is not fixed until the next time the job runs.

NOTE: There is a 2 minute timeout before an "unresponsive" job is picked up. Previously, the timeout was 1 hour. See http://world.episerver.com/documentation/Release-Notes/ReleaseNote/?releaseNoteId=CMS-6821.