use alert state changes counter as secondary version

This commit is contained in:
bergquist
2018-10-01 15:58:30 +02:00
parent 1be8fb76b8
commit 75f832cda8
9 changed files with 54 additions and 9 deletions
+11 -4
View File
@@ -277,19 +277,26 @@ func SetAlertNotificationStateToPendingCommand(ctx context.Context, cmd *m.SetAl
sql := `UPDATE alert_notification_state SET
state = ?,
version = ?,
updated_at = ?
updated_at = ?,
alert_rule_state_updated_version = ?
WHERE
id = ? AND
version = ?`
(version = ? OR alert_rule_state_updated_version < ?)`
res, err := sess.Exec(sql, cmd.State.State, cmd.State.Version, timeNow().Unix(), cmd.State.Id, currentVersion)
res, err := sess.Exec(sql,
cmd.State.State,
cmd.State.Version,
timeNow().Unix(),
cmd.AlertRuleStateUpdatedVersion,
cmd.State.Id,
currentVersion,
cmd.AlertRuleStateUpdatedVersion)
if err != nil {
return err
}
affected, _ := res.RowsAffected()
if affected == 0 {
return m.ErrAlertNotificationStateVersionConflict
}