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

Rakesh R commented on BOOKKEEPER-688:
-------------------------------------

Adding null check is fine. Firstly I also had same fix in mind, while looking 
at the code I got interested in state transitions and just tried an idea:). But 
with my approach, channel closure breaks the atomicity as its not setting to 
null. I've seen the existing testcase is skipping the disconnected/closed 
channel since the channel is null.

By looking at the log pattern, the test case failure with my patch is due to :
1) Successfully establish channel and now the state becomes CONNECTED
2) Say disconnects, here first sets state to DISCONNECTED and closing the 
channel outside synchronized block. Actually it may take few moments to close 
the channel.
3) At the same time CheckThread enters into the synchronized block and seen 
DISCONNECTED state and channel.isConnected() true.This causes the failure.

{code}
2013-10-04 11:04:40,408 - INFO  - [New I/O client worker 
#6-3:PerChannelBookieClient$1@128] - Successfully connected to bookie: [id: 
0x00a19cc5, /67.195.138.28:55764 => 
asf004.sp2.ygridcore.net/67.195.138.28:15003]
2013-10-04 11:04:40,409 - ERROR - [Thread-6:TestPerChannelBookieClient$6@200] - 
State(DISCONNECTED) and channel(true) inconsistent [id: 0x00a19cc5, 
/67.195.138.28:55764 => asf004.sp2.ygridcore.net/67.195.138.28:15003]
2013-10-04 11:04:40,409 - INFO  - [Thread-5:PerChannelBookieClient@456] - 
Disconnected from bookie channel [id: 0x00a19cc5, /67.195.138.28:55764 :> 
asf004.sp2.ygridcore.net/67.195.138.28:15003]
{code}

> NPE exception in PerChannelBookieClient
> ---------------------------------------
>
>                 Key: BOOKKEEPER-688
>                 URL: https://issues.apache.org/jira/browse/BOOKKEEPER-688
>             Project: Bookkeeper
>          Issue Type: Bug
>    Affects Versions: 4.2.0
>            Reporter: Rakesh R
>            Assignee: Rakesh R
>             Fix For: 4.3.0
>
>         Attachments: 
> 0001-BOOKKEEPER-688-NPE-exception-in-PerChannelBookieClie.patch, 
> BOOKKEEPER-688_branch_4_2.patch, BOOKKEEPER-688_trunk.patch, 
> PerChannelBookieClient-ConnectionState-diagram.png
>
>
> NPE exception in PerChannelBookieClient:
> {code}
> 2013-10-04 11:56:34,526 - INFO  - 
> [NIOServerFactory-15099:NIOServerFactory$Cnxn@246] - Peer closed connection. 
> rc=-1 java.nio.channels.SocketChannel[connected local=/10.18.170.130:15099 
> remote=/10.18.170.130:53945]
> 2013-10-04 11:56:34,526 - INFO  - [Thread-93:PerChannelBookieClient@493] - 
> Disconnected from bookie channel [id: 0x006287d3, /10.18.170.130:53945 :> 
> /10.18.170.130:15099]
> 2013-10-04 11:56:34,526 - INFO  - [New I/O client worker 
> #90-3:PerChannelBookieClient$1@137] - Successfully connected to bookie: [id: 
> 0x01964fe8, /10.18.170.130:53951 => /10.18.170.130:15100]
> 2013-10-04 11:56:34,542 - INFO  - 
> [NIOServerFactory-15100:NIOServerFactory$Cnxn@246] - Peer closed connection. 
> rc=-1 java.nio.channels.SocketChannel[connected local=/10.18.170.130:15100 
> remote=/10.18.170.130:53951]
> 2013-10-04 11:56:34,542 - INFO  - [Thread-93:PerChannelBookieClient@493] - 
> Disconnected from bookie channel [id: 0x01964fe8, /10.18.170.130:53951 :> 
> /10.18.170.130:15100]
> 2013-10-04 11:56:34,542 - WARN  - [New I/O client worker 
> #90-3:PerChannelBookieClient@274] - Add entry operation failed
> java.lang.NullPointerException
>       at 
> org.apache.bookkeeper.proto.PerChannelBookieClient.addEntry(PerChannelBookieClient.java:258)
>       at 
> org.apache.bookkeeper.proto.BookieClient$2.operationComplete(BookieClient.java:138)
>       at 
> org.apache.bookkeeper.proto.BookieClient$2.operationComplete(BookieClient.java:1)
>       at 
> org.apache.bookkeeper.proto.PerChannelBookieClient$1.operationComplete(PerChannelBookieClient.java:173)
>       at 
> org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:381)
>       at 
> org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:372)
>       at 
> org.jboss.netty.channel.DefaultChannelFuture.setSuccess(DefaultChannelFuture.java:316)
>       at 
> org.jboss.netty.channel.socket.nio.NioWorker$RegisterTask.run(NioWorker.java:767)
>       at 
> org.jboss.netty.channel.socket.nio.NioWorker.processRegisterTaskQueue(NioWorker.java:256)
>       at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:198)
>       at 
> org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
>       at 
> org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:44)
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
>       at java.lang.Thread.run(Thread.java:619)
> 4 Oct, 2013 11:56:34 AM org.jboss.netty.channel.DefaultChannelFuture
> WARNING: An exception was thrown by ChannelFutureListener.
> {code}
> Here the operation which is performed is
> step-1 addEntry asynchronously
> step-2 Immediately after adding the entry, close the bookie client



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to