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

   ## Current Behavior
   
   After a Dubbo gray selector has a cached target, applying a new selector 
handle does not reconcile the routing caches to that full configuration:
   
   1. Updating the handle to `[]` returns before clearing 
`SELECTOR_CACHED_HANDLE` or `UpstreamCacheManager`.
   2. Replacing gray target A with gray target B updates the selector handle 
cache to B, but `UpstreamCacheManager.submit` merges B into existing upstream 
state without removing omitted A.
   
   `ApacheDubboGrayLoadBalance` checks whether the selector handle cache is 
nonempty and selects candidates from `UpstreamCacheManager`, so the retained 
targets remain routing candidates. Invalidating Dubbo reference caches at the 
beginning of `handlerSelector` does not clear either of these gray-routing 
caches.
   
   ## Expected Behavior
   
   A full selector-handle update should make the gray-routing candidates match 
the latest configured gray targets. An empty list should clear gray routing; 
replacing A with B should remove A from the candidate cache.
   
   ## Reproduction
   
   Use the actual `AbstractDubboPluginDataHandler` with a minimal subclass that 
no-ops only external Dubbo reference initialization/invalidation. Use the real 
selector cache and `UpstreamCacheManager`; disable global upstream checks and 
mark the targets with `healthCheckEnabled=false` for a deterministic local 
probe.
   
   1. Create a selector with ID `gray-selector`, `continued=true`, and handle:
   
   ```json
   
[{"protocol":"dubbo://","upstreamUrl":"127.0.0.1:20880","gray":true,"weight":1,"status":true,"healthCheckEnabled":false}]
   ```
   
   2. Call `handlerSelector`, then set the handle to `[]` and call it again.
   3. As a control, call `removeSelector` explicitly.
   4. Seed target A again, then replace the handle with the same single-target 
configuration using `127.0.0.1:20881` (B). Call `handlerSelector` and inspect 
both caches.
   
   Observed against the current handler, upstream entity/identity and manager 
sources:
   
   ```text
   BEFORE grayCached=1 upstreams=1
   AFTER_EMPTY grayCached=1 upstreams=1
   REMOVE_CONTROL grayCached=0 upstreams=0
   AFTER_REPLACE_TARGET grayCached=1 upstreams=2
   REPLACEMENT_UPSTREAM_URLS=[127.0.0.1:20880, 127.0.0.1:20881]
   ```
   
   No network calls or live Dubbo registry/provider deployment were used. The 
probe verifies the stale cache states; the routing consumer was verified in 
source.
   
   ## Location
   
   - 
[AbstractDubboPluginDataHandler.java:83](https://github.com/apache/shenyu/blob/b2bc43376a0146684faf6d45a6832d201fc61f45/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-dubbo/shenyu-plugin-dubbo-common/src/main/java/org/apache/shenyu/plugin/dubbo/common/handler/AbstractDubboPluginDataHandler.java#L83):
 returns for an empty full handle before the cleanup branch.
   - 
[AbstractDubboPluginDataHandler.java:93](https://github.com/apache/shenyu/blob/b2bc43376a0146684faf6d45a6832d201fc61f45/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-dubbo/shenyu-plugin-dubbo-common/src/main/java/org/apache/shenyu/plugin/dubbo/common/handler/AbstractDubboPluginDataHandler.java#L93):
 caches the new gray list and submits it to the shared manager.
   - 
[AbstractDubboPluginDataHandler.java:103](https://github.com/apache/shenyu/blob/b2bc43376a0146684faf6d45a6832d201fc61f45/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-dubbo/shenyu-plugin-dubbo-common/src/main/java/org/apache/shenyu/plugin/dubbo/common/handler/AbstractDubboPluginDataHandler.java#L103):
 existing selector-removal path clears both caches.
   - 
[UpstreamCacheManager.java:149](https://github.com/apache/shenyu/blob/b2bc43376a0146684faf6d45a6832d201fc61f45/shenyu-loadbalancer/src/main/java/org/apache/shenyu/loadbalancer/cache/UpstreamCacheManager.java#L149):
 submit processes supplied targets without removing omitted existing entries.
   - 
[ApacheDubboGrayLoadBalance.java:53](https://github.com/apache/shenyu/blob/b2bc43376a0146684faf6d45a6832d201fc61f45/shenyu-plugin/shenyu-plugin-proxy/shenyu-plugin-rpc/shenyu-plugin-dubbo/shenyu-plugin-apache-dubbo/src/main/java/org/apache/shenyu/plugin/apache/dubbo/proxy/ApacheDubboGrayLoadBalance.java#L53):
 the load balancer uses cached gray presence and shared upstream candidates.
   
   ## Impact And Suggested Fix
   
   Clearing gray configuration can leave gray routing active. 
Replacing/removing a target can leave requests eligible for an address no 
longer present in the latest selector configuration, while it remains otherwise 
available.
   
   Handle empty input as a valid configuration replacement and reconcile the 
previous/full gray upstream set with the new one, removing omitted candidates 
from both routing and health-check state. Preserve the shared manager's 
incremental semantics for other callers where needed. Avoid clearing unrelated 
rule configuration when merely reconciling gray candidates.
   
   Priority: P2 / Medium. Confidence: high for cache behavior; routing effect 
is supported by the actual Apache Dubbo gray load-balancer consumer, without a 
complete request-flow integration run.
   
   ## Environment And Related Issues
   
   Apache ShenYu `2.7.2-SNAPSHOT`, `master` at 
`b2bc43376a0146684faf6d45a6832d201fc61f45`.
   
   - #7438 (closed) concerned same-address entries collapsing across 
group/version; this reproduction uses distinct addresses and the current 
group/version-aware identity implementation.
   - #6479 concerns discovery-upstream deletion propagation. Here 
`handlerSelector` receives the updated full handle successfully, but its own 
gray caches remain stale.
   - #5802 concerns an earlier gray load-balancing NPE, not selector 
configuration reconciliation.
   - Empty and replacement variants are consolidated here because they affect 
the same full-selector update contract.
   - Open and closed issue searches and current open PR titles were checked 
before filing.
   


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