liuzongliang0202 opened a new issue, #4543:
URL: https://github.com/apache/rocketmq/issues/4543

   Namesrv uses HashMap to save active brokers, and enables scheduled tasks to 
scan inactive brokers for more than 2 minutes, deleting them from the table. 
But hashmap#hashiterator#remove method may throw new 
concurrentmodificationexception(), and the occurrence of an uncapped exception 
in the scheduled task thread will cause the current task to never be executed 
again
   
       
this.scheduledExecutorService.scheduleAtFixedRate(NamesrvController.this.routeInfoManager::scanNotActiveBroker,
 5, 10, TimeUnit.SECONDS);
   
   
   
   
       public int scanNotActiveBroker() {
           int removeCount = 0;
           Iterator<Entry<String, BrokerLiveInfo>> it = 
this.brokerLiveTable.entrySet().iterator();
           while (it.hasNext()) {
               Entry<String, BrokerLiveInfo> next = it.next();
               long last = next.getValue().getLastUpdateTimestamp();
               if ((last + BROKER_CHANNEL_EXPIRED_TIME) < 
System.currentTimeMillis()) {
                   RemotingUtil.closeChannel(next.getValue().getChannel());
                   it.remove();
                   log.warn("The broker channel expired, {} {}ms", 
next.getKey(), BROKER_CHANNEL_EXPIRED_TIME);
                   this.onChannelDestroy(next.getKey(), 
next.getValue().getChannel());
                   removeCount++;
               }
           }
           return removeCount;
       }


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