dmsolr opened a new pull request, #7814:
URL: https://github.com/apache/shenyu/pull/7814

   ## Why
   
   Issue #7791: after a Dubbo gray selector has a cached target, a full 
selector-handle update does not reconcile the gray routing caches to the latest 
configuration.
   
   - Updating the handle to `[]` returned early, before clearing 
`SELECTOR_CACHED_HANDLE` or `UpstreamCacheManager`, so gray routing stayed 
active after the configuration was cleared.
   - Replacing gray target A with B updated the selector handle cache to B, but 
`UpstreamCacheManager.submit` merged B into the existing upstream state without 
removing the omitted A.
   
   `ApacheDubboGrayLoadBalance` picks candidates from `UpstreamCacheManager` 
whenever the selector handle cache is nonempty, so the retained targets 
remained routing candidates and kept receiving traffic.
   
   ## What
   
   In `AbstractDubboPluginDataHandler#handlerSelector`, treat the full handle 
as the authoritative gray target set:
   
   - Clear the selector's stale upstream state (`removeByKey`) before 
submitting the new gray list, so omitted targets are removed from both the 
routing and health-check caches instead of being merged and retained.
   - Handle an empty/non-gray handle as a valid configuration replacement: 
clear the gray routing caches (`SELECTOR_CACHED_HANDLE` + 
`UpstreamCacheManager`) without touching unrelated rule configuration.
   - Guard the reconciliation against a blank selector id.
   
   The shared manager's incremental `submit` semantics are preserved for other 
callers (divide, websocket, discovery); no change to `UpstreamCacheManager`.
   
   ## Tests
   
   `AbstractDubboPluginDataHandlerTest`:
   
   - `emptyHandleClearsGrayRoutingCaches` - seeding a gray target then applying 
`[]` clears both the selector handle cache and the upstream candidates.
   - `replacingGrayTargetRemovesOmittedUpstream` - replacing `127.0.0.1:20880` 
(A) with `127.0.0.1:20881` (B) leaves only B as a candidate.
   
   Verified with JDK 17: `shenyu-plugin-dubbo-common` (12 tests) and 
`shenyu-plugin-apache-dubbo` handler/load-balance tests (5) pass; checkstyle 
clean.
   
   Fixes #7791
   


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