diff --git a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtx.java b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtx.java index 8ab39302f3..53aee852c5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtx.java +++ b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/OpenFileCtx.java @@ -199,9 +199,9 @@ private void dump() { try { synchronized (this) { // check if alive again - Preconditions.checkState(dumpFile.createNewFile(), - "The dump file should not exist: %s", dumpFilePath); - dumpOut = new FileOutputStream(dumpFile); + Preconditions.checkState(dumpFile.createNewFile(), + "The dump file should not exist: %s", dumpFilePath); + dumpOut = new FileOutputStream(dumpFile); } } catch (IOException e) { LOG.error("Got failure when creating dump stream " + dumpFilePath, e); @@ -239,6 +239,10 @@ private void dump() { && nonSequentialWriteInMemory.get() > 0) { OffsetRange key = it.next(); WriteCtx writeCtx = pendingWrites.get(key); + if (writeCtx == null) { + // This write was just deleted + continue; + } try { long dumpedDataSize = writeCtx.dumpData(dumpOut, raf); if (dumpedDataSize > 0) { @@ -262,16 +266,30 @@ private void dump() { @Override public void run() { while (activeState && enabledDump) { - if (nonSequentialWriteInMemory.get() >= DUMP_WRITE_WATER_MARK) { - dump(); - } - synchronized (OpenFileCtx.this) { - if (nonSequentialWriteInMemory.get() < DUMP_WRITE_WATER_MARK) { - try { - OpenFileCtx.this.wait(); - } catch (InterruptedException e) { + try { + if (nonSequentialWriteInMemory.get() >= DUMP_WRITE_WATER_MARK) { + dump(); + } + synchronized (OpenFileCtx.this) { + if (nonSequentialWriteInMemory.get() < DUMP_WRITE_WATER_MARK) { + try { + OpenFileCtx.this.wait(); + if (LOG.isDebugEnabled()) { + LOG.debug("Dumper woke up"); + } + } catch (InterruptedException e) { + LOG.info("Dumper is interrupted, dumpFilePath= " + + OpenFileCtx.this.dumpFilePath); + } } } + if (LOG.isDebugEnabled()) { + LOG.debug("Dumper checking OpenFileCtx activeState: " + activeState + + " enabledDump: " + enabledDump); + } + } catch (Throwable t) { + LOG.info("Dumper get Throwable: " + t + ". dumpFilePath: " + + OpenFileCtx.this.dumpFilePath); } } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index cb313b6f5e..ac3bc72606 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -494,6 +494,8 @@ Release 2.1.1-beta - 2013-09-23 HDFS-5231. Fix broken links in the document of HDFS Federation. (Haohui Mai via jing9) + HDFS-5249. Fix dumper thread which may die silently. (brandonli) + Release 2.1.0-beta - 2013-08-22 INCOMPATIBLE CHANGES