drush-ops / drush

Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt.
https://www.drush.org
2.34k stars 1.08k forks source link

Processing queues results in out of memory errors #6136

Open graber-1 opened 1 month ago

graber-1 commented 1 month ago

Describe the bug This happens when invoking a Drush process from a drush command:

    $site_alias = $this->siteAliasManager()->getSelf();
    $process = $this->processManager()->drush($site_alias, QueueCommands::RUN, ['some_queue_name']);
    $process->run($process->showRealtime()->hideStdout());

The same queue is processed with cron without out of memory errors, the queue has around 1000 items.

Workaround I implemented processing in batches, something like:

    $site_alias = $this->siteAliasManager()->getSelf();
    $process = $this->processManager()->drush($site_alias, QueueCommands::RUN, ['some_queue_name']);

   do {
      // Enqueue a batch of items.
        $this->someEnqueuer->enqueueBatch($sandbox);

        // Process queue.
        $process->run($process->showRealtime()->hideStdout());
      }

    } while (!$this->someEnqueuer->someIsFinishedMethod());