Giter Club home page Giter Club logo

Comments (27)

tj avatar tj commented on August 16, 2024

haha yeah i've definitely noticed that too. but i was testing something else so i didn't look into it much yet

from kue.

tj avatar tj commented on August 16, 2024

hmm it seems like they are ordered correct, however without a refresh they seem to be tacked on the bottom regardless of priority, kinda funky, looking into it

from kue.

tj avatar tj commented on August 16, 2024

oh nvm it's because the dom elements are not sorted so existing ones stay where they are

from kue.

tj avatar tj commented on August 16, 2024

verified that they are processed in proper order as well

from kue.

alvinsw avatar alvinsw commented on August 16, 2024

As of version 0.4.1, they are still not processed in proper order. A queue is intuitively expected to be FIFO, but redis sorted set is sorting the elements numerically only for the score. Kue implementation is to use the priority number for redis score. This means that a job with the same priority is sorted based on the id as STRING instead of NUMBER. A job with id 10 will be processed before job with id 2. I think this is unintuitive and a violation of the queue principle. This bug is clearly demonstrated in this screencast: http://nodetuts.com/tutorials/27-kue-jobs.html#video

from kue.

sebicas avatar sebicas commented on August 16, 2024

I have the same problem... any ideas of how can this be fixed?

from kue.

imZack avatar imZack commented on August 16, 2024

I still can't get the correct order of jobs. (version 0.7.5)
Something wrong with me?
gut

from kue.

behrad avatar behrad commented on August 16, 2024

First, Jobs are ordered by their priority not job ids.
Secondly, New jobs are added at the bottom of your loaded page, you may refresh your page then to see them in priority order.

from kue.

imZack avatar imZack commented on August 16, 2024

Yep, I got it. But I noticed the commits above provides sorting function by id, it works well as it should be therefore when the UI web scrolling down, loading more data(by increasing ends range) the job list did't sorted correctly(the json api's output is always ordered by id) that's what I mentioned.

from kue.

behrad avatar behrad commented on August 16, 2024

That sort function has been merged long ago...

it's because the dom elements are not sorted so existing ones stay where they are

Anyone can help providing a patch?

from kue.

imZack avatar imZack commented on August 16, 2024

So this issue should be reopen? Because the issue just had been solved partially (JSON API).
I will trying to make a patch in next few days.

from kue.

behrad avatar behrad commented on August 16, 2024

This should be handled in client in an efficient way, any patch is welcome.

from kue.

nisaacson avatar nisaacson commented on August 16, 2024

I am still seeing an issue of jobs processing in the incorrect order. I want to process earlier jobs first. I understand that priority has precedence over id but i need to process an arbitrary amount of jobs where the only sorting criteria is earlier jobs get processed before later jobs.

If I set all jobs to have the same priority, then the order jobs get processed is 1, 10...2

Is there a way I can force FIFO behavior on the queue so that jobs get processed with ids 1, 2, 3...10?


Perhaps the kue code needs to be changed to something like this answer http://stackoverflow.com/a/13820749 to maintain the proper sorting in redis.

Right now when I look at the list of inactive test_job_type in redis I see

127.0.0.1:6379> zrange  q:jobs:test_job_type:inactive 0 -1 withscores
 1) "1"
 2) "-10"
 3) "10"
 4) "-10"
 5) "11"
 6) "-10"
 7) "12"
 8) "-10"
 9) "13"
10) "-10"
11) "14"
12) "-10"
13) "15"
14) "-10"
15) "2"
16) "-10"
17) "3"
18) "-10"
19) "4"
20) "-10"
21) "5"
22) "-10"
23) "6"
24) "-10"
25) "7"
26) "-10"
27) "8"
28) "-10"
29) "9"
30) "-10"

from kue.

behrad avatar behrad commented on August 16, 2024

Yes, I was aware of this. The source is lexicographic ordering of set id's in redis. That link provides an implementation which is simple but ugly, let me think more on this, Thank you for the link.

from kue.

nisaacson avatar nisaacson commented on August 16, 2024

One option is to zero pad the to the front of the job id when saving to the sorted set in redis, and then call parseInt when fetching them back to get an actual numerical id.

One downside is there an upper bound on how many jobs can be stored that is controlled by the amount of zeros prepended to the front

var id = 1

var redisJobID = 000000001
// add job to redis inactive sorted set
...

/// Then change the zpop to call parseInt on the reply from redis
self.zpop(client.getKey('jobs:' + self.type + ':inactive'), function (err, id) {
  if (err || !id) {
    self.job = null;
    return fn(err /*|| "No job to pop!"*/);
  }
  id = parseInt(id, 10)
  Job.get(id, fn);

from kue.

nisaacson avatar nisaacson commented on August 16, 2024

I put together a sample implementation here https://github.com/nisaacson/kue/tree/padded-job-id

from kue.

bblack avatar bblack commented on August 16, 2024

@nisaacson : Instead of appending zeroes, we can avoid the upper limit by pre-pending to the string a byte such as ? that is ordered lexicographically after the characters 1 through 9, in a quantity equal to the length of the job id in base 10.

Additionally, if we require a very recent version of redis, we can specify a substitute string for lexicographic ordering on zadd, that will be used on zrangebylex: http://redis.io/commands/zrangebylex

from kue.

dweinstein avatar dweinstein commented on August 16, 2024

getting sorting to work right on the UI would be awesome πŸ‘

from kue.

behrad avatar behrad commented on August 16, 2024

the sorting issue is not related to UI and is builtin in regard with how Redis sorting works. Please read linked issues above in detail...
This will be fixed in later versions

from kue.

invernizzie avatar invernizzie commented on August 16, 2024

The fact that this bug is still open means kue does not actually behave as a priority queue?
I'd appreciate if someone would let me know before I actually try it, and save me some precious time.

This sounds weird, however, since kue is avertised as a "priority job queue"...

from kue.

dweinstein avatar dweinstein commented on August 16, 2024

The problem isn't in the job queue or the priority of those jobs, but in the display of the jobs in a web based UI. Often the jobs are not displayed in a sorted (numeric) order, which has been an annoyance for using kue at least for me.

from kue.

behrad avatar behrad commented on August 16, 2024

this is sure a bug within kue, the source is how redis behaves on Sorted Set key collations, However this wont affect the prioritization of jobs, but sorting them.
This will be solved in future minor version bump.

from kue.

invernizzie avatar invernizzie commented on August 16, 2024

Thanks for the clarification.

El jue, mar 5, 2015 21:11, Behrad [email protected] escribiΓ³:

this is sure a bug within kue, the source is how redis behaves on Sorted
Set key collations, However this wont affect the prioritization of jobs,
but sorting them.
This will be solved in future minor version bump.

β€”
Reply to this email directly or view it on GitHub
#33 (comment).

from kue.

behrad avatar behrad commented on August 16, 2024

and this happens just for job ids when most significant digit is moved forward

1
10
100
1000
...

from kue.

behrad avatar behrad commented on August 16, 2024

this is moved to 1.0.0

from kue.

behrad avatar behrad commented on August 16, 2024

#678

from kue.

behrad avatar behrad commented on August 16, 2024

Fixed in 0.10.3

from kue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.