Skip to content

Automatic export is triggered multiple times per process #6140

@BartChris

Description

@BartChris

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.

image

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.

private void activateTasksForClosedTask(Task closedTask) throws DataException, IOException, DAOException {

The code inside activateTask is then calling processAutomaticTask

private void activateTask(Task task) throws DataException, IOException, DAOException {

which will add all automatic tasks to the list automaticTasks

For every task on the list Kitodo will start a TaskScriptThread

for (Task automaticTask : automaticTasks) {
automaticTask.setProcessingBegin(new Date());
TaskScriptThread thread = new TaskScriptThread(automaticTask);
TaskManager.addTask(thread);

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

public boolean startExport(Process process, URI unused) {
if (ConfigCore.getBooleanParameterOrDefaultValue(ParameterCore.ASYNCHRONOUS_AUTOMATIC_EXPORT)) {
TaskManager.addTask(new ExportDmsTask(this, process));
Helper.setMessage(TaskSitter.isAutoRunningThreads() ? "DMSExportByThread" : "DMSExportThreadCreated",
process.getTitle());
return false;

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.

public void generateImages(EmptyTask executingThread, Task task, boolean automatic) throws DataException {

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugexportExport mappings and configurations

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions