alerting: add lock on job to prevent a race condition (#18218)

without this lock there is a race condition between the scheduler and job processing.
This commit is contained in:
Kyle Brandt
2019-09-03 09:14:28 -04:00
committed by GitHub
parent e3181e66b4
commit 364d2358d8
5 changed files with 32 additions and 14 deletions

View File

@@ -22,7 +22,7 @@ func TestEngineTimeouts(t *testing.T) {
setting.AlertingNotificationTimeout = 30 * time.Second
setting.AlertingMaxAttempts = 3
engine.resultHandler = &FakeResultHandler{}
job := &Job{Running: true, Rule: &Rule{}}
job := &Job{running: true, Rule: &Rule{}}
Convey("Should trigger as many retries as needed", func() {
Convey("pended alert for datasource -> result handler should be worked", func() {