Skip to content

Commit

Permalink
fix permanent lock of sequential command, when an error occurs (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
aweichler committed Apr 17, 2024
1 parent e0436e7 commit c65f252
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions src/Command/SequentialProcessQueueCommand.php
Expand Up @@ -75,31 +75,36 @@ protected function execute(InputInterface $input, OutputInterface $output)
exit(1);
}

$itemIds = $this->queueService->getAllQueueEntryIds(ImportProcessingService::EXECUTION_TYPE_SEQUENTIAL);
$itemCount = count($itemIds);

$output->writeln("Processing {$itemCount} items sequentially\n");

$progressBar = new ProgressBar($output, $itemCount);
$progressBar->start();

foreach ($itemIds as $i => $id) {
$this->importProcessingService->processQueueItem($id);
$progressBar->advance();

// call the garbage collector to avoid too many connections & memory issue
if (($i + 1) % 200 === 0) {
\Pimcore::collectGarbage();
try {
$itemIds = $this->queueService->getAllQueueEntryIds(ImportProcessingService::EXECUTION_TYPE_SEQUENTIAL);
$itemCount = count($itemIds);

$output->writeln("Processing {$itemCount} items sequentially\n");

$progressBar = new ProgressBar($output, $itemCount);
$progressBar->start();

foreach ($itemIds as $i => $id) {
$this->importProcessingService->processQueueItem($id);
$progressBar->advance();

// call the garbage collector to avoid too many connections & memory issue
if (($i + 1) % 200 === 0) {
\Pimcore::collectGarbage();
}
}

$progressBar->finish();

$this->release(); //release the lock

$output->writeln("\n\nProcessed {$itemCount} items.");

return 0;
} catch (\Throwable $t) {
$this->release();
throw $t;
}

$progressBar->finish();

$this->release(); //release the lock

$output->writeln("\n\nProcessed {$itemCount} items.");

return 0;
}

/**
Expand Down

0 comments on commit c65f252

Please sign in to comment.