queue icon indicating copy to clipboard operation
queue copied to clipboard

Issue with multiple consumers - re-delivering in progress jobs

Open dmullings opened this issue 2 years ago • 2 comments

Hello,

I'm not sure if I have found a bug or if this just a case of user error.

I am having an issue with running multiple workers on long running jobs (~20 minutes).

When add a message into the queue and then start 2 workers using the following command bin/cake worker -c process-invoices -p process-invoices

Initially, 1 worker will begin to process the job. However, after about 5 minutes, the other worker also begins to start working on the same job.

I have set $maxAttempts = 1 in the job class.

Next, I tried to bind each processor to an unique name bin/cake worker -c process-invoices -p process-invoices1 and bin/cake worker -c process-invoices -p process-invoices2

The message is only picked up by 1 worker, however if another message gets added to the queue, the other worker receives the following error:

[LogicException] Processor was not found. processorName: "process-invoices2" in /var/www/html/vendor/enqueue/enqueue/ArrayProcessorRegistry.php on line 33

And when I don't bind the processor name and run the following command twice to create 2 workers bin/cake worker -c process-invoices

I receive a similar error:

error: [LogicException] Processor was not found. processorName: "Cake\Queue\Queue\Processor63e2a1884f1c4" in /var/www/html/vendor/enqueue/enqueue/ArrayProcessorRegistry.php on line 33

For reference, the config for the queue is:

'Queue' => [
    'process-invoices' => [
        'url' => null,
        'queue' => 'process-invoices',
        'logger' => 'stdout',
        'receiveTimeout' => 10000,
        'storeFailedJobs' => true,
    ],
],

I am unable to figure out a method of having multiple workers without the errors or re-processing jobs. Is there any config setting (visibility timeout) that I am missing to resolve my issues?

Thanks!

dmullings avatar Feb 07 '23 19:02 dmullings

What queue backend are you using? It sounds like a message reservation is running out and the queue is handing out the job a second time.

amayer5125 avatar Feb 08 '23 03:02 amayer5125

I am using Redis. Any idea of what would be causing the reservation to run out or what I need to change to fix the problem? Thanks!

dmullings avatar Feb 08 '23 04:02 dmullings