-
-
Notifications
You must be signed in to change notification settings - Fork 289
Change ordering LIFO to FIFO on delayed jobs #416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change ordering LIFO to FIFO on delayed jobs #416
Conversation
Push in left and pop from right
Without this we can have Live Lock because some Jobs added first never wil be attendend if new jobs won't stop arriving
This is not true. Expired/delayed job will be executed after execution of all new jobs that were pushed in the meantime. So while order of execution may not match order of push (it was never a guarantee in queue), this job will eventually be executed.
mariocamaraneto
commented
May 4, 2021
The delayed job added to the queue can change the order that they were pushed. Eventually the can be executed, but this may delay ther execution significantly.
In servers with a high amount of delayed jobs being added to the queue, the jobs can be delayed for hours. I saw this happening in our servers, where new jobs were being processed almost immedietly, while old jobs were queued for hours.
I attached a file with a simulation, where in the queue with delayed jobs we can see that job p3 can be stuck in waiting "forever" if new delayed jobs keeps being pushed. Like in "live lock".
In queues without delay, all new jobs are pushed to the left and reserved in right. This is exactly I coded in this PR.
mariocamaraneto
commented
May 4, 2021
I made a test to simulate this situation, but I don't like the solution because use many SLEEP and decrease the decreases the speed of tests.
You can see here: https://github.com/mariocamaraneto/yii2-queue/pull/1/files
samdark
commented
May 4, 2021
A test is necessary. Also please add a line for CHANGELOG.
Uh oh!
There was an error while loading. Please reload this page.
Push in left and pop from right
Without this we can have Live Lock because some Jobs added first never wil be attendend if new jobs won't stop arriving