I am using Laravel 5.6 and I am dispatching jobs to a queue and then using supervisor to activate 8 workers on that queue. I was expecting that Laravel will know NOT to run the same job twice but I was surprised to discover that it did.
Same job was taken cared of by more than one worker and therefore weird stuff started to happen.
The thing is that one year ago I wrote the same mechanism for another Laravel project (but on Laravel version 5.1) and the whole thing worked out of the box. I didn't have to configure anything.
Anyone can help?
Thank you.
I was having the exact same problem and It drove me crazy until I managed to solve it!
For some reason Laravel 5.6 creates the "jobs" table with engine=MyISAM which does not support transactions which are necessary for the locking mechanism that prevents the case of job runs twice. I believe that it was different in Laravel 5.1 because I also once wrote an app with Laravel 5.4 and it worked perfectly with 8 workers. When I did the same thing with Laravel 5.6 it didn't work. Same as you describe.
Once I've changed the Engine to InnoDB which supports transactions everything worked as expected and the locking mechanism started to work.
So basically all you need to do is:
ALTER TABLE jobs ENGINE = InnoDB;
Hope that will solve your misery...
$schedule->command('emails:send')->withoutOverlapping();