Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong delay on Repeatable #471

Closed
cheluskin opened this issue Apr 15, 2021 · 7 comments
Closed

wrong delay on Repeatable #471

cheluskin opened this issue Apr 15, 2021 · 7 comments

Comments

@cheluskin
Copy link

"bullmq": "^1.15.1",

  "attempts": 0,
  "delay": 319174534,
  "repeat": {
    "every": 345600000,
    "count": 1
  },
  "jobId": "repeat:5c85d739a61ee58418a16a4b3ddbc475:1618790400000",
  "timestamp": 1618471225466,
  "prevMillis": 1618790400000
}

jobQueue.add(skusInFile[i], {color: 'bird'}, {repeat: { every: 345600000 }});

why delay 319174534?

@manast
Copy link
Contributor

manast commented Apr 15, 2021

Time is divided by 345600000 and then jobs are repeated at every such slot. This is so that it works in a distributed environment without job duplicates.

@manast manast closed this as completed Apr 15, 2021
@cheluskin
Copy link
Author

cheluskin commented Apr 15, 2021

Thanks for the quick response. The job starts 8 hours earlier than intended. How can you avoid this?
I reduced the gap time and now delay 120009. it is not clear what is the logic of the calculation

{
  "attempts": 0,
  "delay": 120009,
  "repeat": {
    "every": 345600,
    "count": 1
  },
  "jobId": "repeat:504b7bb5d03e42f785f70449e48224a2:1618475904000",
  "timestamp": 1618475783991,
  "prevMillis": 1618475904000
}

@manast
Copy link
Contributor

manast commented Apr 15, 2021

You can try using the "startDate" option and a suitable "cron" expression.

@cheluskin
Copy link
Author

cheluskin commented Apr 15, 2021

There is an error in the calculation logic. I understand that you wanted to spread the execution of tasks in time, but now this is unpredictable. No one can know exactly when the task will start. "startDate" not work too

@manast
Copy link
Contributor

manast commented Apr 15, 2021

startDate only works with cron expressions, that will help you to determine exactly when every iteration will be executed.
You can also just use delayed jobs if you want a task to be executed at an exact time.
If you think "repeat.every" does not work correctly please propose an alternative implementation, as mentioned, the repetitions must happen at specific slots to avoid job duplicates across workers running in different nodes.

@cheluskin
Copy link
Author

Thanks for the help. I understand, but I cannot imagine a case when the difference of 8 hours is not critical for a scheduled task. And if the interval is not 4 days, but 40, then it turns out the task will start about a week earlier, if you're lucky. Cron is often not suitable because if you plan every three days, then it breaks the month into sections of 3 and they do not coincide with the beginning of the task again

@manast
Copy link
Contributor

manast commented Apr 15, 2021

@cheluskin you are just considering a case where "repeat.every" is not suitable, but many people is using this feature in many other scenarios happily. You can always implement your repeat using the delay feature so that it fits your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants