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

[Bug]: changePriority Confusing behavior when updating priorities #2801

Open
1 task done
LianZiZhou opened this issue Oct 5, 2024 · 5 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@LianZiZhou
Copy link

Version

latest

Platform

NodeJS

What happened?

const job = await generateQueue.getJob('1');
console.log(job.opts.priority); // 2097052
//jobId 1 before update job.opts.priority is 2097052
await job.changePriority({
  priority: 2097045
});
//jobId 1 after update job.opts.priority is still 2097052
const _job = await generateQueue.getJob(job.id);
console.log(_job.opts.priority); //still 2097052

When I look up the raw Redis key, I got this
bull:generate:1 => {b'timestamp': b'1728168935500', b'priority': b'2097045', b'delay': b'0', b'name': b'1', b'opts': b'{"removeOnComplete":1000,"removeOnFail":5000,"priority":2097052,"delay":0,"attempts":0}', b'data': b'{"id":"1"}'}.

The priority has been updated, but opts.priority has not. It looks like the priority update is working, but the results are confusing.I don't know if this is expected behavior and will the priority change really make that task be picked earlier?

How to reproduce.

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@LianZiZhou LianZiZhou added the bug Something isn't working label Oct 5, 2024
@roggervalf
Copy link
Collaborator

hi @LianZiZhou opts is expected to be changed. The only change that matters is priority attribute

@LianZiZhou
Copy link
Author

hi @LianZiZhou opts is expected to be changed. The only change that matters is priority attribute

Thanks for your reply. What is very confusing to me is that in my test opts cannot be changed anyway.
Redis 7.2.4 / NodeJS v20.9.0 / bullmq (4.12.7/5.16.0)

When should opts be updated?
https://github.com/taskforcesh/bullmq/blob/master/src/commands/changePriority-7.lua#L54
Will this script update the parameters in opts?

@manast
Copy link
Contributor

manast commented Oct 6, 2024

@roggervalf it is interesting that there is no priority field for the Job class either, so it is actually not possible to know the priority of a job after it has been changed with changePriority, even though we know it works based on the tests.

@LianZiZhou
Copy link
Author

@roggervalf it is interesting that there is no priority field for the Job class either, so it is actually not possible to know the priority of a job after it has been changed with changePriority, even though we know it works based on the tests.

Maybe need priority field for the Job class? Read priority directly instead of opts.priority .

If I didn't understand this problem, I might only be able to read the raw value from Redis to reliably get the current priority of the Job.

@roggervalf
Copy link
Collaborator

oh yeah I was thinking that we were handling priority as delay attribute, but this is not the case. I'll work on adding this field in Job class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants