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

Skye Wanderman-Milne commented on ZOOKEEPER-1197:
-------------------------------------------------

Based on the second code snippet in the link Patrick found, I've written an 
alternate patch (ZOOKEEPER-1197_shutdown.patch) that waits for the client to 
shutdown the input connection before closing the socket.

I've managed to reproduce the problem locally for testing:
0. My base setup: trunk zk checkout, Ubuntu 12.04, Oracle Java 6, no fancy 
zoo.cfg 
1. I wrote a new 4lw, "long", that prints 100k '.'s followed by a '!' (so you 
can see if it's truncated). See long_4lw.patch.
2. Slow down your localhost connection: sudo tc qdisc add dev lo root netem 
delay 1000ms 
(To undo this command: sudo tc qdisc del dev lo root) 
3. Start a zk server with ./bin/zkServer.sh start 
4. Send a long command: echo long | nc localhost 2181 (I've also been using 
FourLetterWordMain) 
This should fill your terminal with dots, but shouldn't end with a !. If you 
see the !, the output wasn't truncated (i.e., you haven't hit the bug).

The new patch fixes the bug with this setup. Camille's patch also fixes it, 
although I do not fully understand how :) Since Camille reports having problems 
even after applying her patch (which I could not reproduce), this patch 
probably needs further testing as well. It would also be useful to test with a 
variety of clients (it sounds like this is the standard way to close a TCP 
connection, but I'm not positive every client will shut down the connection 
correctly).
                
> Incorrect socket handling of 4 letter words for NIO
> ---------------------------------------------------
>
>                 Key: ZOOKEEPER-1197
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1197
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: server
>    Affects Versions: 3.3.3, 3.4.0
>            Reporter: Camille Fournier
>            Assignee: Camille Fournier
>            Priority: Critical
>             Fix For: 3.5.0
>
>         Attachments: long_4lw.patch, ZOOKEEPER-1197.patch, 
> ZOOKEEPER-1197_shutdown.patch
>
>
> When transferring a large amount of information from a 4 letter word, 
> especially in interactive mode (telnet or nc) over a slower network link, the 
> connection can be closed before all of the data has reached the client. This 
> is due to the way we handle nc non-interactive mode, by cancelling the 
> selector key. 
> Instead of cancelling the selector key for 4-letter-words, we should instead 
> flag the NIOServerCnxn to ignore detection of a close condition on that 
> socket (CancelledKeyException, EndOfStreamException). Since the 4lw will 
> close the connection immediately upon completion, this should be safe to do. 
> See ZOOKEEPER-737 for more details

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to