[ 
https://issues.apache.org/jira/browse/KAFKA-5417?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16044448#comment-16044448
 ] 

ASF GitHub Bot commented on KAFKA-5417:
---------------------------------------

GitHub user dongeforever opened a pull request:

    https://github.com/apache/kafka/pull/3282

    [KAFKA-5417] Clients get inconsistent connection states when SASL/SSL…

    … connection is marked CONECTED and DISCONNECTED at the same time
    
    details are in:
    https://issues.apache.org/jira/browse/KAFKA-5417

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dongeforever/kafka KAFKA-5417

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/kafka/pull/3282.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #3282
    
----
commit 7cad7adcba8ebd4b64a7c7012865ffd5315c5dfe
Author: zander <zhendongliu....@alibaba-inc.com>
Date:   2017-06-09T13:45:59Z

    [KAFKA-5417] Clients get inconsistent connection states when SASL/SSL 
connection is marked CONECTED and DISCONNECTED at the same time

----


> Clients get inconsistent connection states when SASL/SSL connection is marked 
> CONECTED and DISCONNECTED at the same time
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-5417
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5417
>             Project: Kafka
>          Issue Type: Bug
>          Components: clients
>    Affects Versions: 0.10.2.1
>            Reporter: dongeforever
>            Priority: Critical
>             Fix For: 0.10.2.2
>
>
> Assume the SASL or SSL Connection is established successfully, but be reset 
> when writing data into it (This will happen frequently in LVS Proxy 
> environment )
> Selecter poll will act like follows:
> try { 
>    ...
>     //finish connect successfully
>     if (channel.finishConnect()) {
>         this.connected.add(channel.id());    (1)
>      }
>      //the prepare will fail, for sasl or ssl will do handshake and write data
>      //throw exception
>     if (channel.isConnected() && !channel.ready())
>                     channel.prepare();
>    ....
> } catch {
>      close(channel);
>       this.disconnected.add(channel.id());  (2)
> }
> The code line named (1) and (2) will mark the connection CONNECTED and 
> DISCONNECTED at the same time.
> And the NetworkClient poll will:
> handleDisconnections(responses, updatedNow);   //remove the channel
> handleConnections();   //mark the channel CONNECTED
> So get the inconsistent ConnectionStates, and such state will block the 
> messages sent into this channel in Sender:
> For the channel will never be ready and never be connected again:
> public boolean ready(Node node, long now) {
>         if (node.isEmpty())
>             throw new IllegalArgumentException("Cannot connect to empty node 
> " + node);
>         //return false, for the channel dose not exist actually
>         if (isReady(node, now))
>             return true;
>         //return false, for the channel is marked CONNECTED
>         if (connectionStates.canConnect(node.idString(), now))
>             // if we are interested in sending to a node and we don't have a 
> connection to it, initiate one
>             initiateConnect(node, now);
>         return false;
>  }
> So all messages sent to such channel will be expired eventually



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to