Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Issues
  • #228
Closed
Open
Issue created Jan 10, 2016 by Administrator@rootContributor

PriorityQueue priorities messed up?

Created by: yonivy

It seems that the jobs do not adhere to the priorities.

I didn't see any tests related to actually checking we get a correct order of execution, so I ran some myself.

This is just the "let's log it out" version, no assertions.

queue = new PriorityQueue(queueName);

var lowPJobs = [], mediumPJobs = [], highPJobs = [];

for(var i = 0; i < 4; i++) {
    lowPJobs.push(queue.add({p: 2}, {priority: 'normal'}));
    mediumPJobs.push(queue.add({p: 1}, {priority: 'medium'}));
    highPJobs.push(queue.add({p: 0}, {priority: 'high'}));
}

// wait for all the jobs to enter the queue
Promise
    .all(lowPJobs, mediumPJobs, highPJobs)
    .then(function() {
        queue.process(function(job, done) {
            console.log(job.data);
            done();
        });
    });

and the output is always

{ p: 0 }
{ p: 0 }
{ p: 1 }
{ p: 1 }
{ p: 1 }
{ p: 1 }
{ p: 2 }
{ p: 2 }
{ p: 2 }
{ p: 2 }
{ p: 0 }
{ p: 0 }

this 'pattern' is repeating every time the 'highest' priority is present more than 2 times.

Does anybody know anything about why and maybe a clue to what should be fixed? I've skimmed through the code and nothing really caught my eye.

Assignee
Assign to
Time tracking