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
  • #446
Closed
Open
Issue created Feb 16, 2017 by Administrator@rootContributor

locally pausing a queue does not work when there are multiple active workers

Created by: josephwarrick

queue.pause(true /* local */);

will never resolve if there is more than one simultaneously active node process working on jobs.

This means that if we try to do

queue.pause(true /* local */).then(function() {
  queue.close();
});

our queue will stop processing jobs, but will never close.

This is happening because:

Suppose queueA and queueB are two separate node processes working on the same queue. Suppose they are each processing one job.

If we call queueA.pause(true), queueA will count how many jobs are active globally, getting 2.

queueA will then wait for 2 (completed|failed|stalled) events before pausing.

Since queueA is only working on one job, and queueA won't start any more jobs because it is trying to pause, there will only ever be 1 (completed|failed|stalled) event, so queueA will never pause.

I don't think that listening for a (completed|failed|stalled) event globally is a good solution here. Suppose queueB processes two jobs before queueA can finish it's one job. Then queueA would receive two events, even though queueA is still working on it's job, and would pause incorrectly.

Assignee
Assign to
Time tracking