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
  • #787
Closed
Open
Issue created Nov 14, 2017 by Administrator@rootContributor

Stalled jobs aren't removed by removeRepeatable

Created by: Sicria

If a job stalls and the process is restarted, when the process comes back up, they report as being stalled, then attempt to run, if successful they reschedule themselves to run again.

Before scheduling a job to be repeated I call queue.removeRepeatable to remove any previously set jobs of this same type.

It seems that removeRepeatable isn't removing jobs which previously stalled?

Here's a wrapper function I created to schedule jobs if the config option is enabled.

export const scheduleTask = ({ queue }, name) => {
  // Identifier = Queue/Process
  const identifier = () => `[${[queue.name, name].filter(i => i).join('/')}]`;
  const configName = `Tasks.${queue.name}.${name}`;

  // Ensure the configs are correct
  if (!config.has(configName)) {
    logger.info(identifier(), 'SETUP FAILED', 'Task does not have any configs');
    return;
  }

  const { enabled, cron } = config.get(configName);

  // Remove previous repeatable jobs
  queue.removeRepeatable(name, { cron });

  if (!enabled) {
    logger.info(identifier(), 'SETUP FAILED', 'Task does not have enabled config');
    return;
  }

  if (!cron) {
    logger.crit(identifier(), 'SETUP FAILED', 'Task does not have cron config');
    return;
  }

  logger.info(identifier(), 'SETUP');

  // Add the reoccurring task
  queue.add(name, null, { repeat: { cron } });
};
  await (async () => {
    const queue = await createQueue('feed');
    const utils = { app, queue };

    // Assign the process for this queue
    queue.process('fetch', ({ data }) =>
      fetchFeed(utils, data),
    );

    // Schedule reoccurring tasks
    scheduleTask(utils, 'fetch');

    return queue;
  })();

The createQueue method above calls queue.empty() internally, so shouldn't that also remove stalled jobs, or any jobs within that queue for that matter?

Assignee
Assign to
Time tracking