OKAPI: Prevent Export-Worker run twice at a time for a task

XMLWordPrintable

    • High
    • None
    • Enhancement: With workflow-Actions it can happen, a task-export is triggered twice. To prevent corrupted exports we prevent, an OKAPI Export workers can run parallel for a task
    • None

      PROBLEM

      With workflow-Actions it can happen, a task-export is triggered twice. This leads to multiple OKAPI Export Workers running in parallel for the same task leading to corrupt exports due to parallel file-access (files being removed/locked)

      SOLUTION
      To prevent this, we check if there is already a running OKAPI Export-Worker for the current task in a OKAPI Export-Workers work() and If so, we terminate with adding an error to the task-log what went wrong. This strategy can also be added to the general export-worker to prevent two export-workers are working at the same time.

      "FRONTEND"-TESTS

      This feature can not really be frontend tested. To test:

      • create a task on your local instance, ideally with several workfiles that are processed with OKAPI (html, office, ...), e.g. _nextcloud/Developer/test-data/BY-ISSUE/TRANSLATE-5706/multi-docx-en-de.zip
      • trigger the export with the following code added to Translate5\MaintenanceCli\Command\DevelopmentDevCommand: t5 dev
      • vary the sleep-time to mimic some scenarios
              $taskId = <YOUR-TASK-ID>;
      
              $task = new \editor_Models_Task();
              $task->load($taskId);
      
              $worker1 = new \editor_Models_Export_Worker();
              $worker1->initExport($task, false);
              $worker2 = new \editor_Models_Export_Worker();
              $worker2->initExport($task, false);
      
              $logger = \Zend_Registry::get('logger');
              $logger->warn('E9999', 'QUEUED DEV EXPORT', [
                  'task' => $task,
              ]);
      
      
              $worker1->queue();
              sleep(2);
              $worker2->queue();
      

            Assignee:
            Axel Becher
            Reporter:
            Axel Becher
            Axel Becher Axel Becher
            Sanya Mikhliaiev
            Sanya Mikhliaiev
            Sanya Mikhliaiev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None