Skip to content
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

Solved: Job which are queued with high priority were not given priority #827

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

MrSpark2591
Copy link

//registering jobs 
const regJobToProcess = (job) => {
    let job = agenda.create(job.type, job);
    job.schedule('now');
    job.priority(notification.priority || 'low');
    job.save();
};
setTimeout(() => {
    regJobToProcess({ type: 'PROCESS_SMS_OTP', priority: 'low', data: 1 });
    regJobToProcess({ type: 'PROCESS_SMS_OTP', priority: 'high', data: 2 });
}, 5000);

When next job is picked, I expected that it will be the job with high priority. But result was not what i expected and It was the one with low priority. So I have gone through some of the code and found out that sorting order was not right and it was taking nextRunTime 1st and than priority. But for priority queue it should be other way around.

Let me know what is the expected behaviour? If current behaviour is not what is expected please review and merge the PR.

@Uzlopak
Copy link
Contributor

Uzlopak commented May 26, 2020

seems legit

@simllll
Copy link
Contributor

simllll commented Dec 11, 2020

Beware this could be a breaking change.
1.) Behavior changes
2.) Database query changes (other sorting/order means different index is required

@MrSpark2591
Copy link
Author

Beware this could be a breaking change.
1.) Behavior changes
2.) Database query changes (other sorting/order means different index is required

I guess index findAndLockNextJobIndex will be used no need to change it. And as for behavior change, I guess the proposed behavior is the correct one. Let me know if I am missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants