zrlw edited a comment on issue #9210:
URL: https://github.com/apache/dubbo/issues/9210#issuecomment-962615219


   再说一下this.connectivityCheckFuture被创建的新任务重新赋值的问题:
   checkConnectivity异步创建的任务在结束前判断是否有新task,如果有就再次调用checkConnectivity:
   1. this.connectivityCheckFuture在checkConnectivity方法返回调用者之后又被赋了新值,但调用者并不知情;
   2. 调用者在旧的connectivityCheckFuture上等待的结果就是新task未执行完,调用者就继续执行后面的代码,然后出问题,比如:
   https://github.com/apache/dubbo/runs/4130565263?check_suite_focus=true
   ```
   2021-11-07T11:46:56.1815610Z [ERROR] Tests run: 3, Failures: 1, Errors: 0, 
Skipped: 0, Time elapsed: 0.19 s <<< FAILURE! - in 
org.apache.dubbo.rpc.cluster.support.ConnectivityValidationTest
   2021-11-07T11:46:56.1818867Z [ERROR] 
org.apache.dubbo.rpc.cluster.support.ConnectivityValidationTest.testRetry  Time 
elapsed: 0.007 s  <<< FAILURE!
   2021-11-07T11:46:56.1820680Z org.opentest4j.AssertionFailedError: expected: 
<2> but was: <1>
   2021-11-07T11:46:56.1822662Z         at 
org.apache.dubbo.rpc.cluster.support.ConnectivityValidationTest.testRetry(ConnectivityValidationTest.java:190)
   ```
   更新:
   
还不能简单地在checkConnectivity创建的task里面等待新任务结束,那样就违背了checkConnectivity的设计初衷,为了避免长时间占用connectivityExecutor,checkConnectivity采用的是分批处理的策略,所以PR
 #9211 最终这么改了:
   1. 
将checkConnectivity创建的任务变成返回future的Callable类型,如果在任务结束前创建了新任务,则返回新任务的future,否则返回当前future,以让调用者知情。
   2. 
ConnectivityValidationTest的waitRefresh方法的结束条件改为invokersToReconnect列表里没有需要recover的invoker。


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