[BUG] Websocket refresh temporarily removes cached plugin, selector and rule data
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
WebSocket REFRESH and MYSELF handling removes the received Plugin, Selector and Rule entries from the cache, then adds them back one by one.
Request threads read these caches concurrently. Between removal and re-subscription, valid configuration is temporarily unavailable: a plugin may be skipped, or selector/rule matching may fail.
This can happen during synchronization after a WebSocket reconnect or an explicit refresh, even when the configuration has not changed.
Expected Behavior
Refreshing unchanged configuration should not temporarily make it unavailable to requests.
The existing cache should remain readable while the refreshed batch is being built. The completed batch should then become visible in one publication.
Steps To Reproduce
- Configure WebSocket data synchronization and a divide route with one matching selector and rule. Confirm that requests succeed.
- Trigger synchronization by reconnecting the gateway to Admin.
- For deterministic reproduction, pause SelectorDataHandler.doRefresh() immediately after refreshSelectorDataSelf(dataList) and before the subscription loop.
- Send a request to the configured route. The selector is temporarily absent from BaseDataCache, so matching fails.
- Resume synchronization. The selector is added back and matching succeeds again.
Plugin and Rule refresh handlers contain the same remove-then-add interval.
Environment
ShenYu version(s): 2.7.2-SNAPSHOT
Code baseline: master at 7273f23b7, before the proposed fix
Data synchronization: WebSocketDebug logs
No response
Anything else?
The proposed fix is limited to removing the temporary cache gap. It preserves entries absent from the received batch and keeps the existing empty-batch behavior, since REFRESH can also contain single-plugin synchronization data.
Source: apache/shenyu