juicewcode opened a new pull request, #6975:
URL: https://github.com/apache/shenyu/pull/6975
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.
<!-- Describe your PR here; e.g. Fixes #issueNo -->
<!--
Thank you for proposing a pull request. This template will guide you through
the essential steps necessary for a pull request.
-->
Make sure that:
- [x] You have read the [contribution
guidelines](https://shenyu.apache.org/community/contributor-guide).
- [ ] You submit test cases (unit or integration tests) that back your
changes.
- [x] Your local test passed `./mvnw clean install
-Dmaven.javadoc.skip=true`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]