[v11.3.x] Alerting: Update state manager to have immutable state in cache (#96843)

* Alerting: Update state manager to have immutable state in cache (#95985)

* create a new state and set at the end
* propagate labels datasource_uid and ref_id from current state if it's error
* copy the state when apply to all

(cherry picked from commit 420db99d16)

* Remove unused states variables

---------

Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
This commit is contained in:
Alexander Akhmetov
2024-11-25 15:22:40 +01:00
committed by GitHub
co-authored by Yuri Tseretyan
parent 9c7c333856
commit 98be4ac047
6 changed files with 313 additions and 104 deletions
@@ -43,7 +43,7 @@ func BenchmarkGetOrCreateTest(b *testing.B) {
// values := make([]int64, count)
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_ = cache.getOrCreate(ctx, log, rule, result, nil, u)
_ = cache.create(ctx, log, rule, result, nil, u)
}
})
}