[
https://issues.apache.org/jira/browse/HDFS-14088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16708411#comment-16708411
]
Jinglun commented on HDFS-14088:
--------------------------------
Hi [~John Smith], it's a good job:). patch-003 resolves a race condition, and
according to my understanding, the bug is:
Suggesting we have 2 threads A and B holding the same
RequestHedgingProxyProvider.
1. At the begining, currentUsedProxy is pointed to the active NN and everything
is fine.
2. Thread B starts a rpc call and goes to method.invoke(currentUsedProxy.proxy,
args), then a thread switch happens.
3. Thread A detects a rpc failure and calls performFailover(), which assigns
null to variable currentUsedProxy.
4. Thread switch happens, Thread B continues to call
method.invoke(currentUsedProxy.proxy, args), because currentUsedProxy has
already been set to null by Thread A, a NPE is throwed out.
I think the unit test needs more comments. A step by step comments in the unit
test will be very helpful. Otherwise patch-003 looks good to me.
> RequestHedgingProxyProvider can throw NullPointerException when failover due
> to no lock on currentUsedProxy
> -----------------------------------------------------------------------------------------------------------
>
> Key: HDFS-14088
> URL: https://issues.apache.org/jira/browse/HDFS-14088
> Project: Hadoop HDFS
> Issue Type: Bug
> Components: hdfs-client
> Reporter: Yuxuan Wang
> Assignee: Yuxuan Wang
> Priority: Major
> Attachments: HDFS-14088.001.patch, HDFS-14088.002.patch,
> HDFS-14088.003.patch
>
>
> {code:java}
> if (currentUsedProxy != null) {
> try {
> Object retVal = method.invoke(currentUsedProxy.proxy, args);
> LOG.debug("Invocation successful on [{}]",
> currentUsedProxy.proxyInfo);
> {code}
> If a thread run try block and then other thread trigger a fail over calling
> method
> {code:java}
> @Override
> public synchronized void performFailover(T currentProxy) {
> toIgnore = this.currentUsedProxy.proxyInfo;
> this.currentUsedProxy = null;
> }
> {code}
> It will set currentUsedProxy to null, and the first thread can throw a
> NullPointerException.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]