Skip to content

fix: Fix scale rule cache eviction by using rule ids(#6972) - #6975

Open
juicewcode wants to merge 1 commit into
apache:masterfrom
juicewcode:fix/6972-scale-rule-cache-eviction
Open

fix: Fix scale rule cache eviction by using rule ids(#6972)#6975
juicewcode wants to merge 1 commit into
apache:masterfrom
juicewcode:fix/6972-scale-rule-cache-eviction

Conversation

@juicewcode

Copy link
Copy Markdown
Contributor

Fixes #6972
Fix scale rule cache eviction when rules are deleted.

ScaleRuleCache stores rules using metricName as the map key:
ruleCache.put(rule.getMetricName(), rule);
However, ScaleRuleServiceImpl.delete receives database primary keys and passes them directly to the cache removal method:
scaleRuleCache.removeRulesFromCache(ids);
The database deletion uses the same values as primary keys:
DELETE FROM scale_rule WHERE id IN (...)

Because rule IDs and metric names are different fields, the deleted rule may remain in the in-memory cache.

Changes

  • Add removeRulesByIdsFromCache.
  • Locate cached rules by their ScaleRuleDO#id.
  • Remove matching entries using the existing metric-name map key.
  • Add ScaleRuleServiceImpl#delete to use the new method.

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

  - Add cache eviction by database primary key.
  - Keep metric names as cache keys.
  - Add scale rule deletion to remove entries by rule ID.
@juicewcode juicewcode changed the title fix: Fix scale rule cache eviction by using rule IDs. fix: Fix scale rule cache eviction by using rule ids(#6972) Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Scale rule deletion does not evict entries from ScaleRuleCache

1 participant