diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 976ab2c725c..3f421baf174 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1538,6 +1538,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 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 9b33ffc60a8..f0737ad4ce4 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 @@ -1484,14 +1484,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