fix: Fix scale rule cache entity inconsistency(#6623) - #6973
Conversation
- Reuse the persisted entity after create. - Reuse the updated entity after update.
Aias00
left a comment
There was a problem hiding this comment.
Reusing after fixes the double-build inconsistency, but update still leaves a stale cache entry when metricName changes. ScaleRuleCache is keyed by metricName, and the update path only puts the updated rule under the new key; it never removes the old metric-name key for the same id. After renaming a rule, getAllRules() can therefore return both the old cached rule and the updated one until cache reload/restart. Could you load the existing rule before update and remove the old metric-name key when it differs from the new one before adding the updated rule?
PR #6975 is based on this cache consistency fix and additionally removes the stale cache entry when a rule's metricName This PR can be closed in favor of PR #6975. |
- Base the change on the cache consistency fix from pr apache#6973 - Remove stale cache entries by database rule id during deletion - Remove the old metric-name cache key when a rule is renamed - Keep the persisted entity id when caching newly created rules
Fixes #6623
ScaleRuleServiceImpl#createandupdatebuildScaleRuleDOtwice.For create operations without an ID, each call to
buildScaleRuleDOgenerates a new UUID. Therefore, the entity storedin the cache may have a different ID from the entity inserted into the database.
For update operations, rebuilding the entity can also produce a different
dateUpdatedtimestamp.Changes
ScaleRuleDOafter a successful create.afterentity after a successful update.Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.