[BUG] Namespace-scoped empty REFRESH leaves stale state in node/path config centers
Is there an existing issue for this?
- [x] I searched open and closed issues.
Current Behavior
Admin emits a namespace-scoped full REFRESH with an empty list, but node/path-based config-center listeners ignore it. Stale entries remain in the config center instead of converging to the empty Admin state.
DataChangedEventDispatcher forwards the explicit namespace to three-argument listener methods. Their default implementations discard the namespace and invoke two-argument methods. The node listener returns immediately for empty lists; the path listener does no work and skips selector/rule subtree deletion when the list is empty.
Expected Behavior
A full refresh for a supplied namespace must reconcile the covered group to empty, without removing another namespace's data. Empty snapshots are meaningful and cannot rely on extracting namespace/plugin identity from a first row.
Steps To Reproduce
- Use Nacos/Apollo/Polaris or ZooKeeper/Etcd/Consul configuration synchronization.
- Publish selectors/rules in namespace
namespace-a. - Leave old config-center data behind after a missed/failed deletion or other stale-state condition while Admin's current group becomes empty.
- Run namespace synchronize or import followed by
syncAllByNamespaceId(REFRESH, namespace-a). - Observe an empty event carrying namespace-a, but no deletion/replacement of the old config-center entries.
An offline verifier seeded namespace-a and namespace-b in in-memory subclasses of the actual node/path listener bases, then invoked their actual three-argument methods. Current-source output:
PASS node empty REFRESH kept seeded APP_AUTH/PLUGIN/SELECTOR/RULE for namespace-a
PASS node nonempty REFRESH controls delete target namespace stale data and isolate other namespace
PASS path empty REFRESH kept seeded APP_AUTH/PLUGIN/SELECTOR/RULE for namespace-a
PASS path nonempty REFRESH controls delete target namespace stale selector/rule and isolate other namespace
Location And Scope
- DataChangedListener.java:54: namespace-aware defaults delegate to legacy methods.
- AbstractNodeDataChangedListener.java:172: empty selector refresh returns without clearing config-center state; analogous guards apply to covered groups.
- AbstractPathDataChangedListener.java:121: selector refresh deletion requires nonempty data; analogous rule handling starts at line 167.
- SyncDataServiceImpl.java:145: namespace sync publishes plugin/selector/rule events with the namespace.
- AppAuthServiceImpl.java:281: app-auth namespace synchronization emits an empty refresh.
Verified groups: PLUGIN, SELECTOR, RULE, APP_AUTH. Verified shared listener families: node-based Nacos/Apollo/Polaris and path-based ZooKeeper/Etcd/Consul, whose concrete implementations inherit these methods.
This issue does not claim metadata/discovery/proxy-selector/AI-key behavior, nor HTTP/WebSocket behavior.
Impact
Severity: Medium. Confidence: high. Full synchronization cannot repair a config center whose last entries became stale after a deletion. Gateways can continue loading old routing/configuration data until an explicit deletion or manual center cleanup succeeds. Normal incremental delete delivery is a separate path; this reproduction targets full-refresh recovery with empty current data.
Suggested Fix And Regression Coverage
Implement namespace-aware full-refresh reconciliation in the node/path abstractions. On empty refresh, use the supplied namespace to remove stale group entries or replace lists with empty state. For selectors/rules, identify stored plugin/group parents without relying on a first current row. Keep CREATE/UPDATE/DELETE semantics and cross-namespace isolation unchanged.
Test previously populated -> empty namespace full refresh for each covered group, and verify another namespace survives. Retain nonempty replacement and ordinary incremental delete controls.
Validation And Related Issues
Reviewed 2.7.2-SNAPSHOT master at 67596c1d228b62da75cd0a0ecb47d0ac5d995384. Isolated verification and leader recompilation/reproduction confirmed the shared listener behavior. Existing AbstractNodeDataChangedListenerTest,AbstractPathDataChangedListenerTest: 8 tests passed.
#6831 fixed nonempty node refresh union behavior. #6832 fixed nonempty multi-plugin path refresh clearing. This is the empty namespace-aware payload discarded before those replacement algorithms can run. #6662/#6663 concern HTTP gateway refresh; #7356 concerns WebSocket convergence. Those channels are outside this finding.
No real config-center deployment was started; proof uses current listener source and in-memory persistence implementations.
👋 Hello @yuluo-yx
A new issue has been opened by @Aias00:
- Title: [BUG] Namespace-scoped empty REFRESH leaves stale state in node/path config centers
- Link: https://github.com/apache/shenyu/issues/7457
Please review when you have time. Thank you! 🙏
Hi I would like to work on this issue. If no one is already working on this one, I will raise a pr.
Hi @GarvSaxena, following up on your assignment on October 15. More than a week has passed, and I could not find a PR for this issue in its timeline or your recent PRs.
Could you share your current progress, any blockers, and when you expect to open a PR? A draft PR is welcome if the work is still in progress. If you have already submitted one, please link it here. If you are no longer planning to work on this, please let us know so the issue can be made available to another contributor.
Hi @Aias00,
Sorry for the delay in getting back to you. I was occupied with some other commitments and couldn't make progress on this issue earlier.
I’ll be working on it and plan to raise a PR within the upcoming week.
Thank you for following up, and apologies again for the delay!
6. Hi @GarvSaxena, following up on your assignment on October 15. More than a week has passed, and I could not find a PR for this issue in its timeline or your recent PRs. Could you share your current progress, any blockers, and when you expect to open a PR? A draft PR is welcome if the work is still in progress. If you have already submitted one, please link it here. If you are no longer planning to work on this, please let us know so the issue can be made available to another contributor.
While reviewing the node/path config-center listeners on master (9dd9a12fb), I found two related REFRESH problems. They are close to this issue's scope and touch the same code, so I'm adding them here instead of opening separate issues. @GarvSaxena, they may be worth covering in the same fix.
1. A non-empty REFRESH does not clean up groups that are absent from the payload.
- Node centers (Nacos, Apollo):
AbstractNodeDataChangedListener.onCommonMultiChangedgroups the payload by plugin name.refreshChangedMapToList(L245-L255) only rewrites the<ns>.selector.<plugin>.listindex, and deletes stale ids, for plugins that appear in the payload. The same applies to rules, proxy selectors and discovery upstreams. - Path centers (ZooKeeper, etcd):
AbstractPathDataChangedListener.onSelectorChanged/onRuleChanged(L119-L128, L161-L170) calldeletePathRecursiveonly for parent paths derived from the payload.
So if plugin B lost all its selectors while a DELETE was missed (for example, a publish failure swallowed by the catch (Exception e) in onCommonMultiChanged), a later "sync all" REFRESH that only contains plugin A leaves B's keys or nodes in place. Restarted gateways still load them. This is the non-empty counterpart of the empty-list case described above.
2. The path-center REFRESH deletes before it re-creates.
For each plugin in the payload, deletePathRecursive(/ns/shenyu/selector/<plugin>) (and the rule path) runs first, and createOrUpdate then writes the nodes one by one. On ZooKeeper and etcd gateways, every NODE_DELETED becomes unCacheSelectorData / unCacheRuleData. Between the recursive delete and the last re-create, gateways have no selectors or rules for that plugin, so requests can fall through as unmatched during a "sync all". The node-center implementation already upserts first and then deletes only the stale ids, which avoids this window.
A REFRESH implementation for path centers that works out the stale set (existing children minus payload ids) and upserts before deleting would address both points, together with the empty-snapshot case in this issue.
Thanks for digging into this - both points line up with the fix in #8452.
- Non-empty REFRESH and groups absent from the payload
Covered for namespace-scoped REFRESH:
Node centers: onSelectorChanged/onRuleChanged/onPluginChanged/onAppAuthChanged now take the event namespace and, on REFRESH, reconcile against the stored indexes (
- Delete-before-recreate in path centers
Also fixed. Path REFRESH no longer does recursive delete + recreate. It upserts the full payload first, then computes existing children - payload ids and deletes only the stale nodes. On ZK/etcd that means no interval where a plugin has zero selectors/rules, which is the same upsert-then-delete ordering the node listener uses.
Metadata, discovery upstream, proxy selector, and AI-key groups are still out of scope here, per the issue; the same treatment for proxy selector/discovery would be a separate change.
Tests cover empty snapshot, non-empty snapshot with a missing plugin, ordering independence, cross-namespace isolation, and the upsert-before-delete ordering.