HDFS-9467. Fix data race accessing writeLockHeldTimeStamp in FSNamesystem. Contributed by Mingliang Liu.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/e556c35b Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/e556c35b Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/e556c35b Branch: refs/heads/yarn-2877 Commit: e556c35b0596700f9ec9d0a51cf5027259d531b5 Parents: fc799ab Author: Jing Zhao <ji...@apache.org> Authored: Wed Nov 25 14:21:06 2015 -0800 Committer: Jing Zhao <ji...@apache.org> Committed: Wed Nov 25 14:22:12 2015 -0800 ---------------------------------------------------------------------- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 11 +++++------ 2 files changed, 8 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/e556c35b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 8fc911c..b085e67 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -2400,6 +2400,9 @@ Release 2.8.0 - UNRELEASED HDFS-9407. TestFileTruncate should not use fixed NN port. (Brahma Reddy Battula via shv) + HDFS-9467. Fix data race accessing writeLockHeldTimeStamp in FSNamesystem. + (Mingliang Liu via jing9) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/e556c35b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 0559288..89df008 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -1498,14 +1498,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, public void writeUnlock() { final boolean needReport = fsLock.getWriteHoldCount() == 1 && fsLock.isWriteLockedByCurrentThread(); + final long writeLockInterval = monotonicNow() - writeLockHeldTimeStamp; + this.fsLock.writeLock().unlock(); - if (needReport) { - long writeLockInterval = monotonicNow() - writeLockHeldTimeStamp; - if (writeLockInterval >= WRITELOCK_REPORTING_THRESHOLD) { - LOG.info("FSNamesystem write lock held for " + writeLockInterval + - " ms via\n" + StringUtils.getStackTrace(Thread.currentThread())); - } + if (needReport && writeLockInterval >= WRITELOCK_REPORTING_THRESHOLD) { + LOG.info("FSNamesystem write lock held for " + writeLockInterval + + " ms via\n" + StringUtils.getStackTrace(Thread.currentThread())); } } @Override