014-code opened a new pull request, #6381:
URL: https://github.com/apache/shenyu/pull/6381

   ### Description
   When the WebSocket connection between admin and bootstrap is closed and
   reconnected, the bootstrap refreshes its local cache by first clearing
   existing data and then reloading from admin one by one. During this
   window period, incoming requests cannot find plugin/selector/rule data
   in cache and fail with errors.
   
   **Root Cause:**
   In `PluginDataHandler`, `SelectorDataHandler`, and `RuleDataHandler`,
   `doRefresh()` calls `refreshXxxDataSelf()` before subscribing new data.
   `refreshXxxDataSelf()` in turn calls `cleanXxxDataSelf()` in `BaseDataCache`,
   which removes all entries present in the new list from the cache, leaving
   the cache empty during the reload window.
   
   **Fix:**
   1. Reverse the refresh order in `doRefresh()`: subscribe new data first,
      then remove stale entries.
   2. Update `cleanPluginDataSelf()`, `cleanSelectorDataSelf()`, and
      `cleanRuleDataSelf()` in `BaseDataCache` to remove entries **not present**
      in the new data list, instead of removing entries that are present.
   
   **Limitation:**
   The current fix for `cleanSelectorDataSelf()` and `cleanRuleDataSelf()`
   operates at the `pluginName` and `selectorId` granularity respectively.
   If a plugin has multiple selectors and only some of them are removed,
   the stale selectors under the same `pluginName` key may not be cleaned up.
   This edge case is not covered by this fix and may require further 
improvement.
   
   ### Tests
   The following existing test methods have been updated to reflect the new
   behavior:
   
   - 
`org.apache.shenyu.plugin.base.cache.BaseDataCacheTest#testCleanPluginDataSelf`
   - 
`org.apache.shenyu.plugin.base.cache.BaseDataCacheTest#testCleanSelectorDataSelf`
   - 
`org.apache.shenyu.plugin.base.cache.BaseDataCacheTest#testCleanRuleDataSelf`
   
   ### Checklist
   - [x] I have submitted the iCLA
   - [x] My code follows the code style of this project
   - [x] I have added tests to cover my changes
   - [x] All new and existing tests passed


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