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] - Nightly job run twice #789

Open
wandering-tales opened this issue Oct 22, 2024 · 1 comment
Open

[BUG] - Nightly job run twice #789

wandering-tales opened this issue Oct 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@wandering-tales
Copy link

wandering-tales commented Oct 22, 2024

Describe the bug

It seems this long standing issue (see #52, #132, #159, and #601) is still unresolved.

I have configured a daily job running at 3:00, which processes a batch of entities relevant to my domain. The job completes in around 170ms:

_, _ = scheduler.NewJob(
		gocron.DailyJob(1, gocron.NewAtTimes(gocron.NewAtTime(3, 0, 0))),
		gocron.NewTask(task.MyTask, myParam1, myParam2),
		gocron.WithEventListeners(
			gocron.AfterJobRunsWithError(func(jobID uuid.UUID, jobName string, err error) {
				log.Printf("failed my task: %v", err)
			})),
)

but this occurred last night:

2024-10-22T03:00:00.245294425Z stderr F 2024/10/22 03:00:00 processing thing with ID 59e50053-0d33-4729-9732-9e69ade399a2
...
2024-10-22T03:00:00.414909773Z stderr F 2024/10/22 03:00:00 processing thing with ID 59e50053-0d33-4729-9732-9e69ade399a2

Version

  • gocron: 2.12.1

Expected behavior

The task should be run only once.

Additional context

I have tested the scheduler behavior locally and the NextRuns method of the job returned what is expected.

@wandering-tales wandering-tales added the bug Something isn't working label Oct 22, 2024
@rsvix
Copy link

rsvix commented Nov 4, 2024

Hello, I'm facing the same issue, but using Gocron version 2.5.0.
It's completely random; some days it happens, some it doesn't.
example:

j, _ := sched.NewJob( gocron.CronJob("0 8 ? * MON,TUE,WED,THU,FRI", false), gocron.NewTask( func() { log.Println("doing stuff") }, ), gocron.WithTags("myCustomTag"), gocron.WithSingletonMode(gocron.LimitModeReschedule), )

EDIT: Since I am using Gocron to add jobs to a queue, I was able to temporarily fix this by adding a constraint to the queue to not accept duplicate inputs created at the exact same timestamp.

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

No branches or pull requests

2 participants