vqianxiao commented on code in PR #15883:
URL: https://github.com/apache/dubbo/pull/15883#discussion_r2642426178


##########
dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java:
##########
@@ -208,27 +211,35 @@ public List<Invoker<T>> list(Invocation invocation) 
throws RpcException {
         BitList<Invoker<T>> availableInvokers;
         SingleRouterChain<T> singleChain = null;
         try {
+            if (routerChain != null) {
+                routerChain.getLock().readLock().lock();
+            }
+            boolean lockAcquired = false;
             try {
-                if (routerChain != null) {
-                    routerChain.getLock().readLock().lock();
+                if (!invokerRefreshReadLock.tryLock(LockUtils.DEFAULT_TIMEOUT, 
TimeUnit.MILLISECONDS)) {
+                    throw new RpcException("Failed to acquire read lock on 
invokerRefreshLock within timeout");
                 }
+                lockAcquired = true;
                 // use clone to avoid being modified at doList().
                 if (invokersInitialized) {
                     availableInvokers = validInvokers.clone();
                 } else {
                     availableInvokers = invokers.clone();
                 }
-
-                if (routerChain != null) {
-                    singleChain = routerChain.getSingleChain(getConsumerUrl(), 
availableInvokers, invocation);
-                    singleChain.getLock().readLock().lock();
-                }
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+                throw new RpcException(
+                        "Interrupted while acquiring read lock for invoker 
access, cause: " + e.getMessage(), e);
             } finally {
-                if (routerChain != null) {
-                    routerChain.getLock().readLock().unlock();
+                if (lockAcquired) {
+                    invokerRefreshReadLock.unlock();
                 }
             }

Review Comment:
   Sorry, I'm not quite sure how our testing should be provided. However, due 
to this issue, our service provider was unable to make normal calls to 
consumers after publishing. I temporarily solved this problem with the 
submitted code. There have been no instances of route rejection in the current 
release



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to