Aias00 opened a new issue, #6832:
URL: https://github.com/apache/shenyu/issues/6832

   ## Description
   On `REFRESH`, `AbstractPathDataChangedListener.onSelectorChanged` takes 
`changed.stream().findFirst()` and uses `firstData.getPluginName()` to build 
`buildSelectorParentPath`, then `deletePathRecursive` on that **single** parent 
path. The same pattern in `onRuleChanged`. But `syncAll`/`syncAllByNamespaceId` 
publish ALL selectors (or rules) of an entire namespace — spanning many plugins 
— in one REFRESH event. Only the first encountered plugin's selector/rule 
parent subtree is recursively deleted; for every other plugin the stale subtree 
is not cleared, and the subsequent per-item `createOrUpdate` only adds/updates 
the new entries without removing deleted siblings.
   
   ## Location
   - 
`shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/AbstractPathDataChangedListener.java:113-121`
 (selector REFRESH), `158-166` (rule REFRESH)
   - trigger: 
`shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SyncDataServiceImpl.java:124-129`
 (`syncAll`), `152-156` (`syncAllByNamespaceId`); callers 
`NamespacePluginController:210`, `ConfigsExportImportController:141`
   
   ## Impact
   On zookeeper/etcd/consul sync backends, a namespace resync or config import 
(reachable via admin controller endpoints) leaves deleted selectors and rules 
for all but one plugin present in the config tree. Gateways syncing from these 
backends continue to load and apply stale selectors/rules — persistent routing 
drift / phantom rules after what should be a full refresh.
   
   ## Suggested fix
   In the REFRESH block, group `changed` by pluginName (and namespaceId) and 
`deletePathRecursive(buildSelectorParentPath(ns, pluginName))` for each 
distinct plugin, instead of only `findFirst()`. Apply the same fix to the rule 
REFRESH block.
   
   ## Related existing
   Distinct from SYNC-3/SYNC-4 (gateway-side `shenyu-sync-data-http` 
`SelectorDataRefresh`/`RuleDataRefresh` NPE on null/empty) and from H-8 
(nacos/apollo/polaris node-based). This is the path-based listener 
(zk/etcd/consul) with a first-plugin-only clear root cause.
   


-- 
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]

Reply via email to