[
https://issues.apache.org/jira/browse/HBASE-19708?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16312409#comment-16312409
]
Chia-Ping Tsai commented on HBASE-19708:
----------------------------------------
Does this change make another NPE when stopping RpcServer?
{code}
@@ -968,6 +971,7 @@ public class RpcServer implements RpcServerInterface,
ConfigurationObserver {
} catch (IOException e) {
LOG.info(getName() + ": exception in closing listener socket. " + e);
}
+ acceptChannel = null;
}
readPool.shutdownNow();
}
{code}
Listener#run() also try to close the {{Listener}} after loop.
{code:title=Listener.java}
public void run() {
LOG.info(getName() + ": starting");
while (running) {
// bababa
}
LOG.info(getName() + ": stopping");
synchronized (this) {
try {
acceptChannel.close(); // here
selector.close();
} catch (IOException ignored) {
if (LOG.isTraceEnabled()) LOG.trace("ignored", ignored);
}
selector= null;
acceptChannel= null;
// clean up all connections
while (!connectionList.isEmpty()) {
closeConnection(connectionList.remove(0));
}
}
}
{code}
No wait exist between listener#interrupt and listener#doStop. It cause the NPE
if the acceptChannel#close is executed after the listener#doStop.
{code:title=RpcServer.java}
@Override
public synchronized void stop() {
LOG.info("Stopping server on " + port);
running = false;
if (authTokenSecretMgr != null) {
authTokenSecretMgr.stop();
authTokenSecretMgr = null;
}
listener.interrupt();
listener.doStop();
responder.interrupt();
scheduler.stop();
notifyAll();
}
{code}
> Avoid NPE when the RPC listener's accept channel is closed
> ----------------------------------------------------------
>
> Key: HBASE-19708
> URL: https://issues.apache.org/jira/browse/HBASE-19708
> Project: HBase
> Issue Type: Bug
> Affects Versions: 0.98.24
> Reporter: Andrew Purtell
> Assignee: Andrew Purtell
> Priority: Minor
> Fix For: 1.3.2, 1.4.1, 1.5.0
>
> Attachments: HBASE-19708-branch-1.patch
>
>
> Rare NPE when the listener's accept channel is closed. We serialize access to
> related state to avoid a previously fixed related NPE and need to do the same
> for {{acceptChannel}}. Seen in a 0.98 deploy but I think applicable to later
> code lines. Let me check.
> Exception in thread "MetadataRpcServer.handler=191,queue=0,port=60020"
> java.lang.NullPointerException
> at
> org.apache.hadoop.hbase.ipc.RpcServer$Listener.getAddress(RpcServer.java:858)
> at
> org.apache.hadoop.hbase.ipc.RpcServer.getListenerAddress(RpcServer.java:2338)
> at org.apache.hadoop.hbase.ipc.CallRunner.run(CallRunner.java:140)
> at
> org.apache.hadoop.hbase.ipc.RpcExecutor.consumerLoop(RpcExecutor.java:133)
> at org.apache.hadoop.hbase.ipc.RpcExecutor$1.run(RpcExecutor.java:108)
> at java.lang.Thread.run(Thread.java:745)
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)