Description
Describe the bug
When a lot of automatic exports are triggered for multiple processes (e.g. after multiple automatic processing steps), it seems that the export for the processes is sometimes triggered two times and the export of the same process appears two times in the task manager.
I tried to trace the behaviour and it seems as if the automatic export is triggered two times, when the previous task is closed and the next task is started and executed automatically. Maybe i am reading the code wrong, but the current implementation seems wrong.
When a task is closed activateTasksForClosedTask
is called, which will activate the following tasks.
The code inside activateTask
is then calling processAutomaticTask
which will add all automatic tasks to the list automaticTasks
For every task on the list Kitodo will start a TaskScriptThread
When this TaskScriptThread
is executed it will get evaluated for the type of task, in the case of the export this will lead to the execution of executeDmsExport
(taskService.executeDmsExport(this.task);
)
This is were the problems might begin, because that method will start another TaskScriptThread
kitodo-production/Kitodo/src/main/java/org/kitodo/export/ExportDms.java
Lines 133 to 138 in ee97b68
In my understanding we now have two threads which will end up doing the exact same thing: Exporting the process.
This is different from generateImages
which seems to get executed in the already existing thread.
We probably should handle the export similar to the generateImages
and not start a Thread, when there is already a thread for the export.
Expected behavior
The export should only be triggered one time per process.
Release
3.6, Master