You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/08/03 01:13:11 UTC

[I] [BUG] ConsulSyncDataService uses non-thread-safe HashMap for shared state accessed by 7 concurrent watcher threads [shenyu]

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

   - Severity: Medium
   - Location:
   `shenyu-sync-data-center/shenyu-sync-data-consul/src/main/java/org/apache/shenyu/sync/data/consul/ConsulSyncDataService.java:63,65` (HashMap fields), `:98` (7-thread `ScheduledThreadPoolExecutor`), `:103-111` (7 scheduled `watcherData0` tasks)
   - 
   Description:
   `consulIndexes` (`Map<String, Long>`) and `cacheConsulDataKeyMap` (`Map<String, List<ConsulData>>`) are plain `HashMap`. The executor has 7 threads and schedules 7 independent `watchConfigKeyValues` tasks (one per watcher path). Each task performs `consulIndexes.get`, `consulIndexes.containsValue` (full-map scan), `consulIndexes.put`, `cacheConsulDataKeyMap.get`, `cacheConsulDataKeyMap.put` on these shared maps. `HashMap` is not safe for concurrent access — structural modifications (put during resize) can corrupt internal structure or lose data; `containsValue` racing with `put` produces inconsistent reads.
   - 
   Impact:
   Under normal multi-path consul operation, concurrent access corrupts data, loses index updates (watcher misses config changes or re-processes them), inconsistent gateway cache state.
   - 
   Suggested fix:
   Change both to `ConcurrentHashMap`.
   - 
   Confidence: High
   - Related existing: none — #5545 (consul client metadata register fails) is a different component/root cause.
   
   ---
   _Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._


-- 
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: notifications-unsubscribe@shenyu.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] ConsulSyncDataService uses non-thread-safe HashMap for shared state accessed by 7 concurrent watcher threads [shenyu]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 closed issue #6783: [BUG] ConsulSyncDataService uses non-thread-safe HashMap for shared state accessed by 7 concurrent watcher threads
URL: https://github.com/apache/shenyu/issues/6783


-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] ConsulSyncDataService uses non-thread-safe HashMap for shared state accessed by 7 concurrent watcher threads [shenyu]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #6783:
URL: https://github.com/apache/shenyu/issues/6783#issuecomment-5161318688

   👋 Hello @Aias00
   
   A new issue has been opened by @Aias00:
   - **Title**: [BUG] ConsulSyncDataService uses non-thread-safe HashMap for shared state accessed by 7 concurrent watcher threads
   - **Link**: https://github.com/apache/shenyu/issues/6783
   
   Please review when you have time. Thank you! 🙏


-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org