apache / apache/shenyu

[BUG] Websocket refresh temporarily removes cached plugin, selector and rule data

Open
#7,034 1 comment 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

### Is there an existing issue for this?

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

1. Configure WebSocket data synchronization and a divide route with one matching selector and rule. Confirm that requests succeed.
2. Trigger synchronization by reconnecting the gateway to Admin.
3. For deterministic reproduction, pause SelectorDataHandler.doRefresh() immediately after refreshSelectorDataSelf(dataList) and before the subscription loop.
4. Send a request to the configured route. The selector is temporarily absent from BaseDataCache, so matching fails.
5. Resume synchronization. The selector is added back and matching succeeds again.

Plugin and Rule refresh handlers contain the same remove-then-add interval.

### Environment

```markdown
ShenYu version(s): 2.7.2-SNAPSHOT
Code baseline: master at 7273f23b7, before the proposed fix
Data synchronization: WebSocket
```

### Debug 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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with SelectorDataHandler.doRefresh(), refreshSelectorDataSelf(dataList), and BaseDataCache to trace how refresh data is removed and published. Compare the corresponding plugin and rule refresh handlers, then verify that the old cache remains readable until the refreshed batch is published and that absent entries and empty-batch behavior remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.