HDFS-9467. Fix data race accessing writeLockHeldTimeStamp in FSNamesystem. Contributed by Mingliang Liu.

(cherry picked from commit e556c35b05)
(cherry picked from commit 288cf8437b)
This commit is contained in:
Jing Zhao 2015-11-25 14:21:06 -08:00 committed by Zhe Zhang
parent 0d8a1636ef
commit 8aa18534d9
1 changed files with 5 additions and 6 deletions

View File

@ -1503,14 +1503,13 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
public void writeUnlock() { public void writeUnlock() {
final boolean needReport = fsLock.getWriteHoldCount() == 1 && final boolean needReport = fsLock.getWriteHoldCount() == 1 &&
fsLock.isWriteLockedByCurrentThread(); fsLock.isWriteLockedByCurrentThread();
final long writeLockInterval = monotonicNow() - writeLockHeldTimeStamp;
this.fsLock.writeLock().unlock(); this.fsLock.writeLock().unlock();
if (needReport) { if (needReport && writeLockInterval >= WRITELOCK_REPORTING_THRESHOLD) {
long writeLockInterval = monotonicNow() - writeLockHeldTimeStamp; LOG.info("FSNamesystem write lock held for " + writeLockInterval +
if (writeLockInterval >= WRITELOCK_REPORTING_THRESHOLD) { " ms via\n" + StringUtils.getStackTrace(Thread.currentThread()));
LOG.info("FSNamesystem write lock held for " + writeLockInterval +
" ms via\n" + StringUtils.getStackTrace(Thread.currentThread()));
}
} }
} }
@Override @Override