[ 
https://issues.apache.org/jira/browse/KAFKA-8182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mark Anderson updated KAFKA-8182:
---------------------------------
    Description: 
When NetworkUtils.initiateConnect calls connectionStates.connecting an 
UnknownHostException can be thrown by ClientUtils.resolve when creating a new 
NodeConnectionState .

In the above case the nodeState map within ClusterConnectionStates will not 
contain an entry for the node ID.

The catch clause within NetworkUtils.initiateConnect immediately calls 
connectionStates.disconnected but this makes the assumption that a 
NodeConnectionState entry exists for the node ID. This assumption is incorrect 
when an UnknownHostException is thrown as described above and leads to an 
IllegalStateException like the following:
{noformat}
java.lang.IllegalStateException: No entry found for connection 2147483645|
  at 
org.apache.kafka.clients.ClusterConnectionStates.nodeState(ClusterConnectionStates.java:339)|
  at 
org.apache.kafka.clients.ClusterConnectionStates.disconnected(ClusterConnectionStates.java:143)|
  at 
org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:926)|
   at 
org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:287)|{noformat}
This is an issue when running in K8s since if a node is marked not ready then 
DNS resolution starts to fail when resolving the address of the broker on that 
node.

  was:
When NetworkUtils.initiateConnect calls connectionStates.connecting an 
UnknownHostException can be thrown by ClientUtils.resolve when creating a new 
NodeConnectionState .

In the above case the nodeState map within ClusterConnectionStates will not 
contain an entry for the node ID.

The catch clause within NetworkUtils.initiateConnect immediately calls 
connectionStates.disconnected but this makes the assumption that a 
NodeConnectionState entry exists for the node ID. This assumption is incorrect 
when an UnknownHostException is thrown as described above and leads to an 
IllegalStateException like the following:
{noformat}
java.lang.IllegalStateException: No entry found for connection 2147483645|
  at 
org.apache.kafka.clients.ClusterConnectionStates.nodeState(ClusterConnectionStates.java:339)|
  at 
org.apache.kafka.clients.ClusterConnectionStates.disconnected(ClusterConnectionStates.java:143)|
  at 
org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:926)|
   at 
org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:287)|{noformat}


> IllegalStateException in NetworkClient.initiateConnect when handling 
> UnknownHostException thrown from ClusterConnectionStates.connecting 
> -----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-8182
>                 URL: https://issues.apache.org/jira/browse/KAFKA-8182
>             Project: Kafka
>          Issue Type: Bug
>          Components: network
>    Affects Versions: 2.2.0, 2.1.1
>            Reporter: Mark Anderson
>            Priority: Major
>
> When NetworkUtils.initiateConnect calls connectionStates.connecting an 
> UnknownHostException can be thrown by ClientUtils.resolve when creating a new 
> NodeConnectionState .
> In the above case the nodeState map within ClusterConnectionStates will not 
> contain an entry for the node ID.
> The catch clause within NetworkUtils.initiateConnect immediately calls 
> connectionStates.disconnected but this makes the assumption that a 
> NodeConnectionState entry exists for the node ID. This assumption is 
> incorrect when an UnknownHostException is thrown as described above and leads 
> to an IllegalStateException like the following:
> {noformat}
> java.lang.IllegalStateException: No entry found for connection 2147483645|
>   at 
> org.apache.kafka.clients.ClusterConnectionStates.nodeState(ClusterConnectionStates.java:339)|
>   at 
> org.apache.kafka.clients.ClusterConnectionStates.disconnected(ClusterConnectionStates.java:143)|
>   at 
> org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:926)|
>    at 
> org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:287)|{noformat}
> This is an issue when running in K8s since if a node is marked not ready then 
> DNS resolution starts to fail when resolving the address of the broker on 
> that node.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to