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

[BUG] - NextRun() method returning a value in the past when using a locker. #828

Closed
manuelarte opened this issue Feb 13, 2025 · 3 comments · Fixed by #829
Closed

[BUG] - NextRun() method returning a value in the past when using a locker. #828

manuelarte opened this issue Feb 13, 2025 · 3 comments · Fixed by #829
Labels
bug Something isn't working

Comments

@manuelarte
Copy link
Contributor

manuelarte commented Feb 13, 2025

Describe the bug

When I call the method NextRun() in a job I get a timestamp in the past. I think it's related to the fact that I am using a gocron.Locker and that particular instance does not get to do the job.
Then I can have the scenario that if for example, if my project have two instances, and I am exposing the nextRun value through an endpoint, the values are different for each instance.

I think I am not explaining myself very good, so that's why I created a repo to show it live, link below.

To Reproduce

I created a gist to describe the scenario:
https://gist.github.com/manuelarte/e33cec46cd8653a5e2731687041a051a

Version

github.com/go-co-op/gocron/v2 v2.15.0

Expected behavior

I would expect the NextRun value to be the same independently if that particular instance got the job last time or not.

Additional context

As mentioned before, I created a repo to easily show the issue https://github.com/manuelarte/cron-job-next-run-issue

@manuelarte manuelarte added the bug Something isn't working label Feb 13, 2025
@JohnRoesler
Copy link
Contributor

Hey @manuelarte,

Sounds like two things here:

  1. Agree, it seems like there is a bug around how the nextRun values are being cleared (or not cleared) in the case of a Locker running.
  2. Having multiple scheduler instances respond with the same nextRun results is outside the scope of what gocron would do. That'd be like an entire scheduler server that handled multiple instances, a datasource, syncing results across, etc.

Thoughts on that?

@manuelarte
Copy link
Contributor Author

Hi @JohnRoesler ,

Thanks for your answer, we can forget about the point 2 indeed, it's out of the scope of this library.
But the 1st point would solve, in my case, the 2nd point.

@manuelarte
Copy link
Contributor Author

manuelarte commented Feb 16, 2025

I realised now that the repo I created was private... now it's public in case you want to see what's happening...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants