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
  • #1284
Closed
Open
Issue created Apr 17, 2019 by Administrator@rootContributor

getRepeatableJobs() returns job data with potentially "invalid" data

Created by: mehdivk

Description

Let's assume that we need to run a task that simply logs the "Hello, world!" every 5 seconds. To do so, I created the following repeatable job on top of the latest version of Bull (3.7.0).

const bullQueue = new BullQueue("HELLO_WORLD_QUEUE", "redis://127.0.0.1");

const name = "HELLO_WORLD";
const data = { job: "data" };
const jobId = "HELLO_WORLD" ;
const repeat = { every: 5 * 1000 };

bullQueue.add(name, data, { jobId, repeat });

Now, let's get a list of repeatable jobs using the getRepeatableJobs API:

const jobs = await bullQueue.getRepeatableJobs();
console.log(JSON.stringify(job, null, "  "));

I got the following log:

[{
    "key": "HELLO_WORLD:HELLO_WORLD_CRON::5000",
    "name": "HELLO_WORLD",
    "id": "HELLO_WORLD_CRON",
    "endDate": null,
    "tz": "5000",
    "next": 1555468465000
 }]

Everything looks good to me except the "tz" field. When configuring the job, I didn't provide the timezone. Here I'm getting value of "every" as "tz" and the "every" field is missing here.

Minimal, Working Test code to reproduce the issue.

const BullQueue = require("bull");

async function example() {
  const bullQueue = new BullQueue("HELLO_WORLD_QUEUE", "redis://127.0.0.1");
  const name = "HELLO_WORLD";
  const data = { job: "data" };
  const jobId = "HELLO_WORLD" ;
  const repeat = { every: 5 * 1000 };

  bullQueue.add(name, data, { jobId, repeat });
  const jobs = await bullQueue.getRepeatableJobs();
  console.log(JSON.stringify(job, null, "  "));
}

example().then(() => process.exit());

Bull version

3.7.0

Additional information

I'm trying to fix a broader problem using the getRepeatableJobs(). Maybe there is a better way to solve this problem but let me explain the problem first.

Initially, we created a repeatable job that was running every 15 mins. Later on we decided to adjust the time to every 30 mins so we went ahead and updated the code. Turns out that Bull kept our old repeatable job as well so currently we got two repeatable jobs: one that runs every 15 mins and the other one every 30 mins. I'm trying to use getRepeatableJobs() to remove the old one as part of the service bootstrap.

Below is what I get from Redis which shows that we got a couple of duplicates there:

127.0.0.1:6379> ZRANGE "bull:DIGITAL_REIGN_QUEUE:repeat" 0 10000
1) "IMPORT_INVOICE_FILES:::10000"
2) "IMPORT_INVOICE_FILES:::5000"
3) "IMPORT_INVOICE_FILES:IMPORT_INVOICE_FILES::10000"
4) "IMPORT_INVOICE_FILES:IMPORT_INVOICE_FILES::5000"
5) "IMPORT_INVOICE_FILES:IMPORT_INVOICE_FILES_CRON::5000"

Thanks for the great work on bull project. It's a great tool.

Assignee
Assign to
Time tracking