ostark / craft-async-queue

Async Queue Handler for Craft 3 and 4
MIT License
93 stars 7 forks source link

Queue jobs not processing #49

Closed GaryReckard closed 2 years ago

GaryReckard commented 2 years ago

I have installed this plugin, but I am not seeing normal queue jobs getting processed. Purchases in my store should send emails, and those jobs are sitting in the queue. If I run the "Async Queue Test", all of the jobs will then process. But I need these emails to get sent out immediately.

When I tested a 2nd order, I noticed the jobs from the first order got processed, but now my queue has jobs from this 2nd order sitting in the queue.

In my local environment, my PHP_BINARY is at /usr/bin/php, and in production, it is in /usr/local/bin/php. In both environments, my open_basedir is not set to anything.

How are the jobs being created during an order handled differently from the Async Queue Test jobs? Why do those get things flowing?

Thanks so much for your help!

Craft CMS: 3.7.24 Craft Async Queue: 2.3 Craft Commerce: 3.4.8

sgtpenguin commented 2 years ago

I'm also starting to notice this problem. Often the queue does not run and I'm seeing sites with 1k+ queued jobs. If I manually run php craft queue/run they start processing immediately.

ostark commented 2 years ago

@GaryReckard I'd love to debug this if you still use the plugin.

GaryReckard commented 2 years ago

Hi @ostark I ended up giving the plugin a try in our production environment, and it seems to be working just fine there. Locally, I still experience the issues I described above, but I am currently just disabling async queue in my local environment. Happy to connect to debug.

OscarBarrett commented 2 years ago

We run into a similar issue: if we end up with failed jobs after a deployment (e.g. section changed, Craft wants to resave entries, fails for some reason) then manually retrying them makes them sit on pending and they never run. As mentioned in the OP, running the queue test gets it started.

mattbloomfield commented 2 years ago

We are noticing this after moving to PHP 8+

icreatestuff commented 2 years ago

Also experiencing this issue since updating Craft to 3.7.34 in the past couple of days.

PHP 7.4 Craft Pro CMS: 3.7.34 Craft Async Queue: 2.3.0

ostark commented 2 years ago

I'll review the changes with Craft 3.7 - maybe I missed something.

bhashkar007 commented 2 years ago

@ostark Did you get a chance to review. I am facing the same issue after Craft update to 3.7+.

icreatestuff commented 2 years ago

I managed to get to the bottom of the issue I had and have it working again now. During a Craft update I needed to update my composer.php to use a PHP version >= 7.3. I then needed to use the PHP_BINARY .env variable to specify the path to the version of PHP I was using and make sure that the open_basedir PHP config setting was setup to include that same path. Once everything was configured to use the same version of PHP the Async Queue came back to life.

For context the site we had trouble with was on a server managed through Plesk with multiple other domains hosted and multiple versions of PHP installed.

sandrodunkel commented 2 years ago

We have the same problem here. Queue jobs are backing up and there seems to be no way to get them working. runQueueAuomatically is set to true – still nothing. We only encounter this problem in our live environments, in our dev environments everything seems to work perfectly fine.

PHP: 7.4 Craft Pro CMS: 3.7.32 Async Queue: 2.3.0

ostark commented 2 years ago

Hi All (@sandrodunkel @bhashkar007 @OscarBarrett @mattbloomfield)

1) Can you push a job (e.g. by editing an Entry) and provide these logs?

tail -f storage/logs/console.log | grep argv -C3
tail -f storage/logs/web.log | grep "async-queue"

2) Do you experience the issue when you use the test tool at domain.com/admin/utilities/async-queue-test

3) Is the path to PHP executable correct?

pimago commented 2 years ago

@ostark Same here. Locally with nitro it's working fine. Also on fortrabbit and arcus. However on a host i am using for a staging environment it does stack up processes unless I run it manually.

  1. Doesn't seem to work on that host. I couldn't find any error related to async-queue in the logs.
  2. yes
  3. I guess so. I didn't change it.
ostark commented 2 years ago

Try

 $(which php) -v

if this is the expected php version, run the following command to get the path to your PHP binary

 which php

and assign this path to the PHP_BINARY ENV var.

mattbloomfield commented 2 years ago

FWIW we solved our issues by updating the path to the PHP executable. Sorry for not responding back here.

pimago commented 2 years ago

php -v returns php7 but I am actually using 8. which doesn't seem to work. I am probably just wasting time with that host.

pimago commented 2 years ago

I tried PHP_BINARY="/usr/bin/php8.0" But this creates an error when I go to the test utility. is_executable(): open_basedir restriction in effect. File(/usr/bin/php8.0) is not within the allowed path(s):

ostark commented 2 years ago

@pimago Maybe you need to ask the host about the right path and of you are allowed to run php cli commands.

pimago commented 2 years ago

I guess it is the correct path. Because that's how I run successfully /usr/bin/php8.0 craft queue/run Or am I confusing that with something else?

ostark commented 2 years ago

Can you try this env var instead?

PHP_PATH=/usr/bin/php8.0

Context: https://github.com/symfony/process/blob/5.4/PhpExecutableFinder.php#L36-L70

pimago commented 2 years ago

Thanks. I tried that. Now the error is ostark\AsyncQueue\Exceptions\PhpExecutableNotFound Unable to find php executable.

I will ask the host what the correct path might be.

pimago commented 2 years ago

The host did some changes so I can use php8 just with the php command instead of /usr/bin/php8.0 I retried php_path and php_binary with the new path but they still throw me the same errors.