[v10.4.x] Alerting: Fix persisting result fingerprint that is used by recovery threshold #91331
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 537f1fb from #91224
What is this feature?
This PR fixes state persister to populate the result fingerprint field introduced in #75189 and accidentally removed in #80384
Also, it updates the state manager to always update result fingerprint when it does not match the existing one and emit a log message.
Why do we need this feature?
PR #80384 introduced a regression, which resulted in ResultFingerprint not being saved to the storage. Therefore, if the Grafana restarts the current state is fetched from the database, and the state's fingerprint remains empty. During the lifetime of the state, the resulting fingerprint is not updated, which breaks recovery threshold functionality that relies on this hash: the state manager provides an empty hash to the evaluator, and that hash does not match anything. Therefore, all dimensions that are supposed to be considered "loaded", and therefore evaluated using the unloading threshold, are evaluated against the loading threshold.
The state remains empty because the state manager never updates the result fingerprint of the existing state.
Who is this feature for?
Users of recovery threshold.
Which issue(s) does this PR fix?:
Related to and potentially fixes #87226