chickenlj commented on code in PR #13773: URL: https://github.com/apache/dubbo/pull/13773#discussion_r1505437938
########## dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java: ########## @@ -348,22 +362,37 @@ public void checkConnectivity() { } // 3. recover valid invoker - for (Invoker<T> tInvoker : needDeleteList) { - if (invokers.contains(tInvoker)) { - addValidInvoker(tInvoker); - logger.info( - "Recover service address: " + tInvoker.getUrl() + " from invalid list."); + LockUtils.safeLock(invokerRefreshLock, LockUtils.DEFAULT_TIMEOUT, () -> { + for (Invoker<T> tInvoker : needDeleteList) { + if (invokers.contains(tInvoker)) { + addValidInvoker(tInvoker); + logger.info("Recover service address: " + tInvoker.getUrl() + + " from invalid list."); + } else { + logger.info( + "The invoker " + tInvoker.getUrl() + + " has been removed from invokers list. Will remove it in reconnect list."); + } + invokersToReconnect.remove(tInvoker); } - invokersToReconnect.remove(tInvoker); - } + }); + } catch (Throwable t) { + logger.error( + LoggerCodeConstants.INTERNAL_ERROR, + "", + "", + "Error occurred when check connectivity. ", + t); } finally { checkConnectivityPermit.release(); } // 4. submit new task if it has more to recover - if (!invokersToReconnect.isEmpty()) { - checkConnectivity(); - } + LockUtils.safeLock(invokerRefreshLock, LockUtils.DEFAULT_TIMEOUT, () -> { + if (!invokersToReconnect.isEmpty()) { + checkConnectivity(); + } + }); Review Comment: I noticed there are three separate code snippets in this method that are protected with locks. Would a single method-level lock do the trick? -- 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-unsubscr...@dubbo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org