HDFS-9467. Fix data race accessing writeLockHeldTimeStamp in FSNamesystem. Contributed by Mingliang Liu.
(cherry picked from commit e556c35b0596700f9ec9d0a51cf5027259d531b5) (cherry picked from commit 288cf8437b7e03f071e95eb05e83a26e58fff26b) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/8aa18534 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/8aa18534 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/8aa18534 Branch: refs/heads/branch-2.7 Commit: 8aa18534d9d1bee03e3a5b8db15d2b2034e3adc6 Parents: 0d8a163 Author: Jing Zhao <ji...@apache.org> Authored: Wed Nov 25 14:21:06 2015 -0800 Committer: Zhe Zhang <z...@apache.org> Committed: Thu Aug 25 10:34:43 2016 -0700 ---------------------------------------------------------------------- .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/8aa18534/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 0971539..bd697e0 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 @@ -1503,14 +1503,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 --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org