diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 0e33c7ff8899..0d48000f9aba 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -281,6 +281,7 @@ field. You can revert this change by configuring tags for the module and omittin - Fixed scheduler shutdown issues which would in rare situations cause a panic due to semaphore misuse. {pull}16397[16397] - Fixed TCP TLS checks to properly validate hostnames, this broke in 7.x and only worked for IP SANs. {pull}17549[17549] - Add support for new `service_name` option to all monitors. {pull}19932[19932]. +- Stop rescheduling tasks of stopped monitors. {pull}20570[20570] *Journalbeat* diff --git a/heartbeat/scheduler/scheduler.go b/heartbeat/scheduler/scheduler.go index 18f927a2d806..87db7075c448 100644 --- a/heartbeat/scheduler/scheduler.go +++ b/heartbeat/scheduler/scheduler.go @@ -188,6 +188,12 @@ func (s *Scheduler) Add(sched Schedule, id string, entrypoint TaskFunc) (removeF var taskFn timerqueue.TimerTaskFn taskFn = func(_ time.Time) { + select { + case <-jobCtx.Done(): + debugf("Job '%v' canceled", id) + return + default: + } s.stats.activeJobs.Inc() lastRanAt = s.runRecursiveJob(jobCtx, entrypoint) s.stats.activeJobs.Dec()