Aias00 commented on code in PR #7681:
URL: https://github.com/apache/shenyu/pull/7681#discussion_r4300860179
##########
shenyu-plugin/shenyu-plugin-base/src/main/java/org/apache/shenyu/plugin/base/cache/BaseDataCache.java:
##########
@@ -160,24 +183,31 @@ private void removeSelectData(final String pluginName,
final String selectorId)
*
* @param pluginName the plugin name
*/
- public void removeSelectDataByPluginName(final String pluginName) {
- selectorMap.remove(pluginName);
+ public synchronized void removeSelectDataByPluginName(final String
pluginName) {
+ List<SelectorData> removed = selectorMap.remove(pluginName);
+ if (Objects.nonNull(removed)) {
+ removed.forEach(selector -> ruleMap.remove(selector.getId()));
+ }
+ version++;
}
/**
* Clean selector data.
*/
- public void cleanSelectorData() {
+ public synchronized void cleanSelectorData() {
selectorMap.clear();
+ ruleMap.clear();
Review Comment:
[blocking] Same protocol issue one level down: `cleanSelectorData()` is
invoked by `refreshSelectorDataAll()`
(CommonPluginDataSubscriber.java:212-216), which
`SelectorDataRefresh.refresh()`
(shenyu-sync-data-http/.../refresh/SelectorDataRefresh.java:70-78) calls on any
SELECTOR-group change — it then re-caches only the selectors. With
`ruleMap.clear()` here, every selector change over HTTP sync drops all rules
until the next RULE push. In a full refresh it is worse:
`DataRefreshFactory.executor` iterates its EnumMap in key ordinal order, and
`ConfigGroupEnum` declares PLUGIN(1), RULE(2), SELECTOR(3)
(shenyu-common/.../ConfigGroupEnum.java:33-48), so the sequence is PLUGIN ->
RULE -> SELECTOR: the RULE step refills `ruleMap`, then the SELECTOR step
clears it again and only selectors are refilled — `ruleMap` stays empty until
an unrelated RULE change arrives. Please restrict this method to `selectorMap`
(master semantics) and keep the rule cleanup in `removeSelectData`, which t
his PR already wires correctly (`ruleMap.remove(selectorId)`).
--
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]