fix: remove faulty size guard so REFRESH cleans up stale plugin/auth/meta config nodes - #7014
Open
dmsolr wants to merge 2 commits into
Open
fix: remove faulty size guard so REFRESH cleans up stale plugin/auth/meta config nodes#7014dmsolr wants to merge 2 commits into
dmsolr wants to merge 2 commits into
Conversation
…meta config nodes (#6874) The REFRESH/MYSELF branch of AbstractNodeDataChangedListener#onCommonChanged only removed stale entries when the old set strictly outnumbered the new one, so refreshes with equal or larger cardinality (e.g. old=[A,B,C,D] -> new=[C,D,E,F]) left orphaned config nodes in nacos/apollo/polaris. Removed the size guard and fixed the stale-entry delConfig call to use the correct namespaced key.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes stale config-node cleanup during namespace-wide REFRESH/MYSELF sync events in AbstractNodeDataChangedListener#onCommonChanged, ensuring removed plugin/app-auth/metadata entries are correctly deleted from config centers even when the refreshed set’s cardinality stays the same (or increases). This aligns admin-side publish/delete behavior with how gateway-side watchers consume {prefix}.list and {prefix}{entryKey} nodes.
Changes:
- Remove the incorrect
old.size() > new.size()guard so stale-entry diffing/deletion always runs forREFRESH/MYSELF. - Fix stale-entry deletion to pass the fully qualified dataId (
configKeyPrefix + staleName) intodelConfig. - Add a regression test covering equal-cardinality replacement (e.g.,
A,B,C,D -> C,D,E,F) and asserting stale entries are deleted.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/AbstractNodeDataChangedListener.java | Always computes/removes stale keys on REFRESH/MYSELF and deletes correctly namespaced per-entry nodes. |
| shenyu-admin-listener/shenyu-admin-listener-api/src/test/java/org/apache/shenyu/admin/listener/AbstractNodeDataChangedListenerTest.java | Adds regression coverage for equal-cardinality REFRESH replacing membership and verifies stale node deletion. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Fixes #6874.
In
AbstractNodeDataChangedListener#onCommonChanged, the REFRESH/MYSELF branch only removed stale plugin/app-auth/metadata config entries when the old set strictly outnumbered the new one (configDataNames.size() > changedList.size()). When a REFRESH replaced the set with equal or larger cardinality but different members (e.g. old=[A,B,C,D], new=[C,D,E,F]), the guard was false, so stale entries A and B were never removed from nacos/apollo/polaris config centers — only orphaned per-entry config nodes remained while the LIST node was overwritten.This path is reached by
syncAllByNamespaceId(REFRESH, ns)fromNamespacePluginControllerandConfigsExportImportController, which publish PLUGIN/AUTH/META REFRESH events spanning a whole namespace. For app-auth this is security-adjacent, since a deleted app key's config node could linger and be served to gateways that read it before the list update propagates.Changes
removeAll) always runs.delConfigcall to use the correctly namespaced key (configKeyPrefix + name) instead of the bare entry name, which was also silently preventing cleanup even when the guard passed.Does this PR introduce a user-facing change?
No.