Author: eli Date: Sun Sep 9 06:44:34 2012 New Revision: 1382413 URL: http://svn.apache.org/viewvc?rev=1382413&view=rev Log: HDFS-2757. Cannot read a local block that's being written to when using the local read short circuit. Contributed by Jean-Daniel Cryans
Modified: hadoop/common/branches/branch-1/CHANGES.txt hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java Modified: hadoop/common/branches/branch-1/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/CHANGES.txt?rev=1382413&r1=1382412&r2=1382413&view=diff ============================================================================== --- hadoop/common/branches/branch-1/CHANGES.txt (original) +++ hadoop/common/branches/branch-1/CHANGES.txt Sun Sep 9 06:44:34 2012 @@ -228,6 +228,9 @@ Release 1.2.0 - unreleased HADOOP-8745. Incorrect version numbers in hadoop-core POM. (Matthias Friedrich via eli) + HDFS-2757. Cannot read a local block that's being written to when + using the local read short circuit. (Jean-Daniel Cryans via eli) + Release 1.1.0 - unreleased INCOMPATIBLE CHANGES Modified: hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java?rev=1382413&r1=1382412&r2=1382413&view=diff ============================================================================== --- hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java (original) +++ hadoop/common/branches/branch-1/src/hdfs/org/apache/hadoop/hdfs/DFSClient.java Sun Sep 9 06:44:34 2012 @@ -2019,6 +2019,10 @@ public class DFSClient implements FSCons return (locatedBlocks == null) ? 0 : locatedBlocks.getFileLength(); } + private synchronized boolean blockUnderConstruction() { + return locatedBlocks.isUnderConstruction(); + } + /** * Returns the datanode from which the stream is currently reading. */ @@ -2130,10 +2134,9 @@ public class DFSClient implements FSCons private boolean shouldTryShortCircuitRead(InetSocketAddress targetAddr) throws IOException { - if (shortCircuitLocalReads && isLocalAddress(targetAddr)) { - return true; - } - return false; + // Can't local read a block under construction, see HDFS-2757 + return shortCircuitLocalReads && !blockUnderConstruction() + && isLocalAddress(targetAddr); } /**