Apply several fixes in for the seamless scheduler #939
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR will combine multiple changes required to replicate and resolve issues in the
SeamlessScheduler.Don't update activities if state decreases
Previously the state machine of the activity was kept directional by the
UpdateActivitymethod. However, the activity data was updated even though the method blocked the state update. This causedActivityCompletedsessions to be overriden byActivityStartsessions during result processing, leading to InvalidCastExceptions further down the road.Behaviour change:
Ready jobs not correctly distributed in slots
The loop over ready jobs did not update the last job that was considered. This caused jobs which would otherwise take on running/completing slot to be considered seperately.
This can have multiple different implications down the line, as we always assumed these jobs to share a slot.
For this we did not find any better minor-conform solution.
IsPrepareOfandIsCleanupOfcompare recipes by idSchedulerExtensions.IsPrepareOfandSchedulerExtensions.IsCleanupOfworked on an object reference equals check.This check works as long as all jobs are created and completed within the lifetime of the process engine, as they are all handed over through the
IJobManagement.Addmethod then.After a restart of the process engine this check fails, however.
As the JobManagement uses the
RecipeProvider, in the case the ProductManagement directly when reloading recipes and as the product management returns a new instance of a recipe on each call, recipes of restored and newly dispatched jobs cannot be compared with the normal reference equals, but need to be compared by Id.Refactore the
SeamlessSchedulerto increase readabilityRunning jobs without running processes are resumed after restart
After a job has dispatched a process for the first time and the process has switched to the running state, the job switches to the running state as well. From here onwords the job is running, it can happen however, that all running processes in the job finish, while there is still a process to be dispatched. This happens when the first activity has not yet been dispatched, because it is waiting for a RTW. If the process engine restarts in this state, we load a job from the database without processes (as completed processes are not loaded by default). We, therefore, have to check whether the job had already recorded successes or failures, which tell us mediately that the process had been started before.
Since the job cannot be completed though (it would not be loaded in that case), we schedule it to be resumed
Note: If the job never had dispatched a process which switched to running before the restart we cannot schedule it as resumed after the restart. A job in the
DispatchedStatedrops back into theInitialStateafter the reload and does not store any information to indicate it would be anything but an initial job. Hence, the creation of a seperate setup for a job which would otherwise have been a drop-in follow-up job won't be fixed and is expected behaviour.ToDo: Update Documentation
ToDo: Update Unit tests for SemalessScheduler