diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index fde6fe7abd0..e01bc94a290 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -247,6 +247,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Fixed excessive memory usage introduced in 7.5 due to over-allocating memory for HTTP checks. {pull}15639[15639] - 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 18f927a2d80..87db7075c44 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()