From f3c6d26781c4d099fad1fb2009dbc8d5f2ad4fcb Mon Sep 17 00:00:00 2001 From: Boqin Qin Date: Thu, 23 Apr 2020 16:49:57 +0800 Subject: [PATCH] notifier: forget unlock before return (#7133) Signed-off-by: BurtonQin Co-authored-by: root --- notifier/notifier.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/notifier/notifier.go b/notifier/notifier.go index b0c1409aac..3f64919c38 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -483,6 +483,7 @@ func (n *Manager) sendAll(alerts ...*Alert) bool { v1Payload, err = json.Marshal(alerts) if err != nil { level.Error(n.logger).Log("msg", "Encoding alerts for Alertmanager API v1 failed", "err", err) + ams.mtx.RUnlock() return false } } @@ -497,6 +498,7 @@ func (n *Manager) sendAll(alerts ...*Alert) bool { v2Payload, err = json.Marshal(openAPIAlerts) if err != nil { level.Error(n.logger).Log("msg", "Encoding alerts for Alertmanager API v2 failed", "err", err) + ams.mtx.RUnlock() return false } } @@ -509,6 +511,7 @@ func (n *Manager) sendAll(alerts ...*Alert) bool { "msg", fmt.Sprintf("Invalid Alertmanager API version '%v', expected one of '%v'", ams.cfg.APIVersion, config.SupportedAlertmanagerAPIVersions), "err", err, ) + ams.mtx.RUnlock() return false } }