[ 
https://issues.apache.org/jira/browse/HADOOP-5859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712832#action_12712832
 ] 

Kan Zhang commented on HADOOP-5859:
-----------------------------------

> Is this done to make the code simpler? Or was there some race condition that 
> this fixes?

I don't see any race condition so far. One potential case is calling 
ackQueue.size() in writeChunk() without holding ackQueue lock, which is ok 
assuming int assignments are atomic. The major reasons for refactoring the 
locks are 1) existing code is bit confusing. Sometimes the dataQueue lock is 
used to protect accesses to not only dataQueue but also currentPacket, 
blockStream, blockReplyStream, etc (see closeInternal() for example), which I 
think is a misuse. 2) I have moved time-consuming operations like RPC call or 
writing to socket out of blocks sync'ed on the dataQueue. So now the only times 
one needs to hold dataQueue or ackQueue lock is when manipulating the queues 
themselves. By merging the 2 locks, code can be simpler.



> FindBugs : fix "wait() or sleep() with locks held" warnings in hdfs
> -------------------------------------------------------------------
>
>                 Key: HADOOP-5859
>                 URL: https://issues.apache.org/jira/browse/HADOOP-5859
>             Project: Hadoop Core
>          Issue Type: Bug
>          Components: dfs
>            Reporter: Kan Zhang
>            Assignee: Kan Zhang
>         Attachments: 5859-21.patch, 5859-22.patch, 5859-26.patch, 
> 5859-4.patch, 5859-5.patch, 5859-8.patch
>
>
> This JIRA fixes the following warnings:
> SWL   org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.closeInternal() calls 
> Thread.sleep() with a lock held
> TLW   wait() with two locks held in 
> org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.flushInternal()
> TLW   wait() with two locks held in 
> org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.flushInternal()
> TLW   wait() with two locks held in 
> org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.writeChunk(byte[], int, int, 
> byte[])

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to