HuangZhenQiu commented on a change in pull request #11541:
[FLINK-15416][network] add task manager netty client retry mechenism
URL: https://github.com/apache/flink/pull/11541#discussion_r404518565
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/netty/PartitionRequestClientFactory.java
##########
@@ -81,14 +92,36 @@ NettyPartitionRequestClient
createPartitionRequestClient(ConnectionID connection
Object old = clients.putIfAbsent(connectionId,
connectingChannel);
if (old == null) {
-
nettyClient.connect(connectionId.getAddress()).addListener(connectingChannel);
-
- client =
connectingChannel.waitForChannel();
-
- clients.replace(connectionId,
connectingChannel, client);
+ int count = 0;
+ ChannelException exception = null;
+ do {
+ try {
+ exception = null;
+ connectingChannel.error
= null;
+ LOG.info("Connecting to
{} at {} attempt", connectionId.getAddress(), count);
+
nettyClient.connect(connectionId.getAddress()).addListener(connectingChannel);
+
+ client =
connectingChannel.waitForChannel();
+
+
clients.replace(connectionId, connectingChannel, client);
+ } catch (ChannelException e) {
+ LOG.error("Failed {}
times to connect to {}", count, connectionId.getAddress(), e);
+ exception = e;
+ }
+ count++;
+ } while (count <= retryNumber);
+
+ if (exception != null) {
+ throw exception;
+ }
}
else if (old instanceof ConnectingChannel) {
- client = ((ConnectingChannel)
old).waitForChannel();
+
+ try {
+ client = ((ConnectingChannel)
old).waitForChannel();
+ } catch (IOException e) {
+ LOG.info("Continue to
waitForChannel until the original thread has completed or failed");
+ }
Review comment:
@pnowojski
The logic is always to let the first requester to retry. For the following
requesters, will always go to wait until the first requester get the client or
finished retry. Otherwise, there will be more retry times than expected.
@zhijiangW
I am not sure whether my understanding is correct or now. Once the
ConnectingChannel is put into clients concurrentMap by the first requester, the
object is never null after that. Thus, other requesters will go to line 97. So
the process is what you described " let A retry connections and B is always
waiting during A retries until final success or failure." Are you aligned?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services