Scheduled job - IsStoppable improvement

Vote:
 

If you create a scheduled job that is marked as stoppable and the job is started manually, two instances of the scheduled job are created. One to perform the job and a second to check to see whether or not the job is stoppable. This could potentially have a large impact on performance if heavy dependencies are injected/resolved in the constructor.

I propose the framework is changed so that the check is performed against the running instance (if available) rather than against a new instance.

Example stack traces:

Call 1

at ScheduleJobTest.ActualJob..ctor() in C:\Test\ScheduleJobTest\ActualJob.cs:line 18
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at EPiServer.DataAbstraction.ScheduledJob.<>c__DisplayClass113_0.b__0()
at System.Threading.Tasks.Task.Execute()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
at System.Threading.ThreadPoolWorkQueue.Dispatch()


Call 2

at ScheduleJobTest.ActualJob..ctor() in C:\Test\ScheduleJobTest\ActualJob.cs:line 18
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at EPiServer.DataAbstraction.ScheduledJob.get_IsStoppable()
at ASP.episerver_cms_admin_databasejob_aspx.__Render__control2(HtmlTextWriter __w, Control parameterContainer) in http://server/EPiServer/CMS/Admin/DatabaseJob.aspx:line 12
#171923
Nov 21, 2016 16:45
Vote:
 

Hi Stuart,

As with some of your other Scheduler suggestions, this has been addressed and the fix will be included in an upcoming release (>10.1). It should be mentioned thought that the change that we implemented was not to check the instance as the job could be executing on another server. Instead we made the decision to only check if a job is stoppable during startup, instead of creating an instance with every request as it was done previously. Hopefully that will improve things slightly for you as well.

Cheers,
Henrik

#172256
Nov 28, 2016 17:18
This thread is locked and should be used for reference only.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.