[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2016-06-21 Thread Hadoop QA (JIRA)

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

Hadoop QA commented on ZOOKEEPER-2091:
--

-1 overall.  Here are the results of testing the latest attachment 
  http://issues.apache.org/jira/secure/attachment/12686301/ZOOKEEPER-2091.patch
  against trunk revision 1748630.

+1 @author.  The patch does not contain any @author tags.

-1 tests included.  The patch doesn't appear to include any new or modified 
tests.
Please justify why no new tests are needed for this 
patch.
Also please list what manual steps were performed to 
verify this patch.

-1 patch.  The patch command could not apply the patch.

Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/3222//console

This message is automatically generated.

> Possible logic error in ClientCnxnSocketNIO
> ---
>
> Key: ZOOKEEPER-2091
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
> Project: ZooKeeper
>  Issue Type: Bug
>  Components: java client
>Affects Versions: 3.4.6
>Reporter: Cheng
>Assignee: Rakesh R
> Fix For: 3.6.0, 3.5.3
>
> Attachments: ZOOKEEPER-2091.patch
>
>
> When SASL authentication is enabled, the ZooKeeper client will finally call 
> ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
> @Override
> void sendPacket(Packet p) throws IOException {
> SocketChannel sock = (SocketChannel) sockKey.channel();
> if (sock == null) {
> throw new IOException("Socket is null!");
> }
> p.createBB();
> ByteBuffer pbb = p.bb;
> sock.write(pbb);
> }
> One problem I can see is that the sock is non-blocking, so when the sock's 
> output buffer is full(theoretically), only part of the Packet is sent out and 
> the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2015-04-11 Thread Hadoop QA (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14491225#comment-14491225
 ] 

Hadoop QA commented on ZOOKEEPER-2091:
--

-1 overall.  Here are the results of testing the latest attachment 
  http://issues.apache.org/jira/secure/attachment/12686301/ZOOKEEPER-2091.patch
  against trunk revision 1672934.

+1 @author.  The patch does not contain any @author tags.

-1 tests included.  The patch doesn't appear to include any new or modified 
tests.
Please justify why no new tests are needed for this 
patch.
Also please list what manual steps were performed to 
verify this patch.

-1 patch.  The patch command could not apply the patch.

Console output: 
https://builds.apache.org/job/PreCommit-ZOOKEEPER-Build/2625//console

This message is automatically generated.

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.2, 3.6.0

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2015-01-13 Thread Rakesh R (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14275242#comment-14275242
 ] 

Rakesh R commented on ZOOKEEPER-2091:
-

OK. Thank you [~hdeng] and [~fournc] for the explanation. Will fix the case of 
#sendPacket() now.

I'd like to learn more on the below code flow, any idea when the following 
condition can occur. Does this harm the clients, should we need to address the 
possible error resulting this.
{code}
if (pendingQueue.size() == 0) {
throw new IOException(Nothing in the queue, but got 
+ replyHdr.getXid());
}
{code}

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2015-01-11 Thread Camille Fournier (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14273116#comment-14273116
 ] 

Camille Fournier commented on ZOOKEEPER-2091:
-

Yes, [~rakeshr], as [~hdeng] says, the doIO is written to accommodate packets 
that are not completely sent; changing that will change the semantics of that 
method and make it blocking for the duration of a packet. You're right that in 
SendPacket we need to handle that and worrying about blocking is not as 
important, but I don't think this is actually an error in doIO.

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-12-30 Thread Camille Fournier (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14261525#comment-14261525
 ] 

Camille Fournier commented on ZOOKEEPER-2091:
-

Any more thoughts on this?

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-12-12 Thread Rakesh R (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14243864#comment-14243864
 ] 

Rakesh R commented on ZOOKEEPER-2091:
-

bq.I am confused how it reads the returning result without finishing sending 
the entire packet?
As I remember the situation happened in one of the cluster due to the heavy 
system resource usage like cpu/memory was high(due to map reduce job execution).
It was continuously hitting the below exception and all the operations was 
failing.
{code}
org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1127)
java.io.IOException: Nothing in the queue, but got 425467
at 
org.apache.zookeeper.ClientCnxn$SendThread.readResponse(ClientCnxn.java:788)
{code}

Now with the patch, the cluster is running and no issue reported till now.

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-12-12 Thread Hongchao Deng (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14244534#comment-14244534
 ] 

Hongchao Deng commented on ZOOKEEPER-2091:
--

Did you try only loop writing in ClientCnxnSocketNIO#SendPacket() and see if it 
works? I can tell that's a problem.

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-12-12 Thread Camille Fournier (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14244659#comment-14244659
 ] 

Camille Fournier commented on ZOOKEEPER-2091:
-

I agree that it seems like only sending the full packet in 
ClientCnxnSocketNIO#SendPacket() would fix this issue. We don't do this in doIO 
presumably because we might only send part of the buffer, then allow another 
read to come in before we send the rest of the packet so as not to block on the 
complete send of the pending outgoing packet? Is that correct for implementing 
the nonblocking socket, can someone verify?

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-12-12 Thread Hongchao Deng (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14244672#comment-14244672
 ] 

Hongchao Deng commented on ZOOKEEPER-2091:
--

bq. then allow another read to come in

From what I understand in the code, reading the returning result for the 
packet sent needs to be complete, a.k.a. after the packet sent completely.
{code}
  if (!incomingBuffer.hasRemaining()) {
...
...
sendThread.readResponse(incomingBuffer);
...
  }
{code}
incomingBuffer needs to be filled.

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-12-12 Thread Camille Fournier (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14244861#comment-14244861
 ] 

Camille Fournier commented on ZOOKEEPER-2091:
-

I'm all the way in the bottom of this code and don't even remember the 
invariants. Why don't we wait till all the bytes are flushed to the buffer if 
we don't read anything until that's done?

FWIW, I looked into the depth's of Netty's NIO socket handling. In particular 
to verify that Netty sockets will sometimes switch to reading before all of the 
outgoing bytes are written, which they will. I thought it was interesting 
though that they also configure a writeSpinCount that lets them try to flush 
all bytes a configurable number of times before going back to the selector to 
do other IO. Might be something worth considering. Or, you know, not doing this 
socket stuff ourselves at all and just using netty :)
https://github.com/netty/netty/blob/0eb059bf58642f3c06144e1ea4a9d6c7632eb4d5/transport/src/main/java/io/netty/channel/nio/AbstractNioByteChannel.java#L198

In conclusion, I think that it may not matter much either way but probably we 
should only add this to the SendPacket method.

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-12-12 Thread Hongchao Deng (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14244878#comment-14244878
 ] 

Hongchao Deng commented on ZOOKEEPER-2091:
--

Thanks [~fournc] for the in-depth thinking. I do have another JIRA, 
ZOOKEEPER-2069 to drive Netty things.

Back to this issue. The problem I can find here is that SendPacket() assumes a 
successful write. The other problem is that Sasl process implementation is too 
hackish. It stops/puts aside the nonblocking write logic. My point is that this 
is a good chance to fix it.

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-12-12 Thread Camille Fournier (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14244892#comment-14244892
 ] 

Camille Fournier commented on ZOOKEEPER-2091:
-

I agree [~hdeng] but I'm not sure what conclusion you're driving to. From my 
observation, we can do one of two obvious things:
1) Only change SendPacket, not doIO, which I *think* I agree should solve the 
observed problem with less impact than the current patch

2) Something more drastic to actually fix the hack that is our current Sasl 
hacks, which I don't have a patch to do and I'm not sure if we have any other 
open tickets that will resolve this.

If we think solution 1 solves the issue, I think it is a simple enough fix to 
go ahead and use while we look into Netty etc.

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-12-12 Thread Rakesh R (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14245244#comment-14245244
 ] 

Rakesh R commented on ZOOKEEPER-2091:
-

bq.Did you try only loop writing in ClientCnxnSocketNIO#SendPacket() and see if 
it works? I can tell that's a problem.

What could be the case [of missing pendingQueue.add(p)| 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?focusedCommentId=14227396page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14227396]
 ?. Unfortunately now I didn't get chance to put one more patch into the 
cluster where it hits this problem.

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-12-10 Thread Camille Fournier (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14241475#comment-14241475
 ] 

Camille Fournier commented on ZOOKEEPER-2091:
-

This seems right... can someone seeing this error try this patch and see if it 
fixes it?

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-12-10 Thread Hongchao Deng (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14241542#comment-14241542
 ] 

Hongchao Deng commented on ZOOKEEPER-2091:
--

Isn't that changing non-blocking IO to blocking again?
I think it's OK to change since in most cases client won't fill out socket 
buffer. However it is an assumption.

bq. the reason is due to not adding the packet to the 'pendingQueue'
I am confused how it reads the returning result without finishing sending the 
entire packet?

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Assignee: Rakesh R
 Fix For: 3.5.1

 Attachments: ZOOKEEPER-2091.patch


 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-11-27 Thread Rakesh R (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14227396#comment-14227396
 ] 

Rakesh R commented on ZOOKEEPER-2091:
-

Hi,

I've seen the following exception in my environment
{code}
org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1127)
java.io.IOException: Nothing in the queue, but got 425467
at 
org.apache.zookeeper.ClientCnxn$SendThread.readResponse(ClientCnxn.java:788)
at 
org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:94)
at 
org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:366)
at 
org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1106)
{code}

I'm thinking the reason is due to not adding the packet to the 'pendingQueue'. 
It looks like similar problem occurred here also in the below snippet. What do 
you say?
{code}
ClientCnxnSocketNIO.java

sock.write(p.bb);
if (!p.bb.hasRemaining()) {
.
.
.
pendingQueue.add(p);
}
{code}

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Priority: Minor

 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-11-27 Thread Cheng (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14227572#comment-14227572
 ] 

Cheng commented on ZOOKEEPER-2091:
--

Hi Rakesh,

By the following call flow:
SendThread#run()
  - ZooKeeperSaslClient#initialize()
- ZooKeeperSaslClient#sendSaslPacket()
  - ClientCnxn#sendPacket()
- SendThread#sendPacket()
  - ClientCnxnSocketNIO#sendPacket() 
It seems that the SaslPacket has been put into the pendingQueue after it is 
sent to the ZooKeeper Server. So when the SASL response comes, it will not find 
the corresponding Packet in the pendingQueue.

Is the analysis correct ?

 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Priority: Minor

 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (ZOOKEEPER-2091) Possible logic error in ClientCnxnSocketNIO

2014-11-27 Thread Cheng (JIRA)

[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14227576#comment-14227576
 ] 

Cheng commented on ZOOKEEPER-2091:
--

Sorry, it should be:  It seems that the SaslPacket has NOT been put into the 
pendingQueue after it is sent to the ZooKeeper Server. 


 Possible logic error in ClientCnxnSocketNIO
 ---

 Key: ZOOKEEPER-2091
 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2091
 Project: ZooKeeper
  Issue Type: Bug
  Components: java client
Affects Versions: 3.4.6
Reporter: Cheng
Priority: Minor

 When SASL authentication is enabled, the ZooKeeper client will finally call 
 ClientCnxnSocketNIO#sendPacket(Packet p) to send a packet to server:
 @Override
 void sendPacket(Packet p) throws IOException {
 SocketChannel sock = (SocketChannel) sockKey.channel();
 if (sock == null) {
 throw new IOException(Socket is null!);
 }
 p.createBB();
 ByteBuffer pbb = p.bb;
 sock.write(pbb);
 }
 One problem I can see is that the sock is non-blocking, so when the sock's 
 output buffer is full(theoretically), only part of the Packet is sent out and 
 the communication will break.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)