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] - OneTimeJob Missing Execution #773

Open
gaoyaxuan opened this issue Sep 7, 2024 · 1 comment
Open

[BUG] - OneTimeJob Missing Execution #773

gaoyaxuan opened this issue Sep 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@gaoyaxuan
Copy link

Describe the bug

It is not executing according to LimitModeWait mode, but rather behaving like LimitModeReschedule.

To Reproduce

Steps to reproduce the behavior:

func main() {
	s, _ := gocron.NewScheduler(gocron.WithLimitConcurrentJobs(10, gocron.LimitModeWait))
	s.Start()
	fmt.Println("begin", time.Now().Format("2006-01-02 15:04:05"))
	_, _ = s.NewJob(
		gocron.OneTimeJob(gocron.OneTimeJobStartDateTimes(time.Now().Add(3*time.Second), time.Now().Add(6*time.Second), time.Now().Add(15*time.Second))),
		gocron.NewTask(
			func() error {
				fmt.Println("Run time:", time.Now().Format("2006-01-02 15:04:05"))
				time.Sleep(10 * time.Second)
				return nil
			},
		),
		gocron.WithSingletonMode(gocron.LimitModeWait),
	)

	select {
	case <-time.After(15 * time.Minute):
	}

}

Execution Results:

begin 2024-09-07 15:26:27
Run time: 2024-09-07 15:26:30
Run time: 2024-09-07 15:26:42

time.Now().Add(6*time.Second) not running
If you delete gocron.WithLimitConcurrentJobs(10, gocron.LimitModeWait) or set gocron.WithLimitConcurrentJobs(1, gocron.LimitModeWait) , job all will run

Version

v2.11.0

@gaoyaxuan gaoyaxuan added the bug Something isn't working label Sep 7, 2024
@JohnRoesler
Copy link
Contributor

hi @gaoyaxuan

This looks similar to the issues discussed in #722.

What's the use case for running both WithLimitConcurrentJobs and WithSingletonMode?

It does look like there is an odd bug going on here, given changing the limit for WithLimitConcurrentJobs effects whether or not the job runs 3 times, or only 2 times.

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