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
  • #297
Closed
Open
Issue created May 16, 2016 by Administrator@rootContributor

Cleaning is broken (or I'm doing something wrong)

Created by: ghost

(this is similar to an issue I opened some time ago and then closed because I couldn't reproduce it)

If I call the clean function periodically, sooner or later I get the following error:

Error: Could not get lock for job: 2738. Cannot remove job.

This is not unlike #282 (closed) which also appeared to be triggered by cleaning, but that's ancient history at this point.

I finally found some time to write a smaller test program that triggers this error, but it probably isn't small enough. I'll trim it down, remove Ramda etc. Until the next version, this is the best I have. It takes some time to trigger the error. I made sure the process terminates when the error occurs.

Edit: updated to make it happen quicker

var Promise = require('bluebird'),
    Queue = require('bull');

const
    RHOST = 'localhost',
    RPORT = 6379,
    procTime = 40,
    concurrency = 4,
    jobCreationDelay = 10,
    cleanDelay = 40;

var trace = (x) => {
        console.log(x);
        return x;
    },
    printJobMessage = (j) => {
        trace('Processing job; here\'s a random number: ' + j.data.message);
        return Promise.delay(procTime);
    },
    printErrorAndQuit = (e) => {
        console.log(e);
        process.exit(1);
    };


var q = Queue('testq', RPORT, RHOST);

q.on('error', printErrorAndQuit);
q.process(concurrency, printJobMessage);

//clean every second
var cleanLoop = () => Promise
    .all([
        Promise.resolve('CLEANING STARTED').then(trace),
        q.clean(0, 'completed'),
        q.clean(0, 'failed')
    ])
    .then(() => trace('CLEANING FINISHED'))
    .delay(cleanDelay)
    .then(() => process.nextTick(cleanLoop));

var addJob = (x) => {
    q.add(x);
    return x;
};

var jobLoop = () => Promise
    .resolve({message: Math.random()})
    .then(addJob)
    .delay(jobCreationDelay)
    .then(() => process.nextTick(jobLoop));

cleanLoop();
jobLoop();

Here's the extremely boring log. Error at the very bottom.

Assignee
Assign to
Time tracking