cherryMJY opened a new pull request, #10179:
URL: https://github.com/apache/rocketmq/pull/10179

   Brief Description
   The topicGroupTable in ConsumerManager uses HashSet to store consumer 
groups, which is not thread-safe. When multiple consumers concurrently register 
with the same topic via heartbeat requests, HashSet.add() may lose entries due 
to race conditions.
   
   Concurrent scenarios that trigger this bug:
   
   Multiple consumers start up simultaneously and send heartbeat requests
   Network reconnect triggers batch consumer re-registration
   Proxy syncs consumer info to broker concurrently
   Impact:
   
   Consumer groups may not be recorded in topicGroupTable, causing message 
routing failures
   In extreme cases, HashSet internal structure may be corrupted, leading to 
infinite loops during iteration
   Solution:
   Replace HashSet with ConcurrentHashMap.newKeySet() which provides 
thread-safe add/remove operations using CAS + synchronized mechanism. This 
pattern is already used in other RocketMQ components:
   
   LiteSubscriptionRegistryImpl.liteTopic2Group
   TopicList.topicList
   LiteSubscription.liteTopicSet
   Modified files:
   
   broker/src/main/java/org/apache/rocketmq/broker/client/ConsumerManager.java


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