HDFS-9467. Fix data race accessing writeLockHeldTimeStamp in FSNamesystem. Contributed by Mingliang Liu.
(cherry picked from commit e556c35b0596700f9ec9d0a51cf5027259d531b5) (cherry picked from commit 288cf8437b7e03f071e95eb05e83a26e58fff26b)
This commit is contained in:
parent
0d8a1636ef
commit
8aa18534d9
@ -1503,16 +1503,15 @@ public void writeLockInterruptibly() throws InterruptedException {
|
|||||||
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;
|
|
||||||
if (writeLockInterval >= WRITELOCK_REPORTING_THRESHOLD) {
|
|
||||||
LOG.info("FSNamesystem write lock held for " + writeLockInterval +
|
LOG.info("FSNamesystem write lock held for " + writeLockInterval +
|
||||||
" ms via\n" + StringUtils.getStackTrace(Thread.currentThread()));
|
" ms via\n" + StringUtils.getStackTrace(Thread.currentThread()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasWriteLock() {
|
public boolean hasWriteLock() {
|
||||||
return this.fsLock.isWriteLockedByCurrentThread();
|
return this.fsLock.isWriteLockedByCurrentThread();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user