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

Using the latest version currently, I encountered a situation where the execution occurs twice. After multiple tests, I found that the occurrence of execution twice is sporadic, and I am not sure under what circumstances it occurs. #601

Closed
JohnRoesler opened this issue Oct 27, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@JohnRoesler
Copy link
Contributor

          Using the latest version currently, I encountered a situation where the execution occurs twice. After multiple tests, I found that the occurrence of execution twice is sporadic, and I am not sure under what circumstances it occurs.
Starting server at 0.0.0.0:8881...
{"@timestamp":"2023-10-27T16:43:41.435+08:00","caller":"handler/routes.go:25","content":"--running--","level":"info"}

{"@timestamp":"2023-10-27T16:45:00.000+08:00","caller":"handler/routes.go:25","content":"--running--","level":"info"}
{"@timestamp":"2023-10-27T16:45:00.000+08:00","caller":"handler/routes.go:25","content":"--running--","level":"info"}

{"@timestamp":"2023-10-27T16:48:00.000+08:00","caller":"handler/routes.go:25","content":"--running--","level":"info"}
{"@timestamp":"2023-10-27T16:48:00.000+08:00","caller":"handler/routes.go:25","content":"--running--","level":"info"}

my code:

      s.
	Cron("*/3 * * * *").
	SingletonMode().
	WaitForSchedule().
	Do(func() {
		logx.Info("--running--")
	})

However, when I switched to a lower version for testing, I found that the execution twice situation did not occur.

require(
        //github.com/go-co-op/gocron v1.35.2 // indirect
        github.com/go-co-op/gocron v1.16.3
)

Originally posted by @leafney in #52 (comment)

@JohnRoesler JohnRoesler added v1 bug Something isn't working labels Oct 28, 2023
@JohnRoesler
Copy link
Contributor Author

@leafney if you're up for it. Check out the v2 branch. It's in early testing, but this should be completely solved there!

@leafney
Copy link

leafney commented Oct 30, 2023

@leafney if you're up for it. Check out the v2 branch. It's in early testing, but this should be completely solved there!

Sure. I'll try it.

@leafney
Copy link

leafney commented Oct 30, 2023

func V2Test() {
	s, _ := gocron.NewScheduler()

	s.NewJob(
		//gocron.DurationJob(time.Second*5),
		gocron.CronJob("*/2 * * * *", false),
		gocron.NewTask(func() {
			log.Println("--v2 v2 v2--")
		}),
		gocron.WithSingletonMode(gocron.LimitModeReschedule),
	)

	s.Start()
}

The v2 version did not find repeated executions, perfect.

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