Alerting: Ensure case-sensitive ordering for alert rule group column
The query which fetches alert rules in a paginated manner ordered by `rule_group` can result in strange and inconsistent ordering when the database uses a case-insensitive collation for the `rule_group` column. This can lead to scenarios where rules from different groups are interleaved in the results, making pagination unreliable and the returned number of rule_groups incorrect. Related to #88990
This commit is contained in:
committed by
Moustafa Baiou
parent
684156fdf1
commit
6f7c525213
@@ -156,4 +156,6 @@ func (oss *OSSMigrations) AddMigration(mg *Migrator) {
|
||||
ualert.DropTitleUniqueIndexMigration(mg)
|
||||
|
||||
ualert.AddStateFiredAtColumn(mg)
|
||||
|
||||
ualert.CollateAlertRuleGroup(mg)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package ualert
|
||||
|
||||
import "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
|
||||
// CollateAlertRuleGroup ensures that rule_group column collates.
|
||||
func CollateAlertRuleGroup(mg *migrator.Migrator) {
|
||||
mg.AddMigration("ensure rule_group column is case sensitive in returned results", migrator.NewRawSQLMigration("").
|
||||
Mysql("ALTER TABLE alert_rule MODIFY rule_group VARCHAR(190) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NOT NULL;"))
|
||||
}
|
||||
Reference in New Issue
Block a user