Skip to content

Commit b6430f0

Browse files
committed
Add failing regression test for SPARK-8062
1 parent 23bf307 commit b6430f0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

core/src/test/scala/org/apache/spark/metrics/InputOutputMetricsSuite.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,28 @@ class InputOutputMetricsSuite extends FunSuite with SharedSparkContext with Shou
106106
}
107107
}
108108
}
109+
110+
test("exceptions while getting IO thread statistics should not fail tasks / jobs (SPARK-8062)") {
111+
// For some reason, the following code needs to be called in order for this regression test to
112+
// fail and reproduce the bug. The fact that this is necessary suggests that there may be other
113+
// bugs in our InputOutputMetrics code; SPARK-8086 tracks progress towards investigating this
114+
// issue, since fixing it is out of scope for SPARK-8062.
115+
val fs = FileSystem.getLocal(new Configuration())
116+
val outPath = new Path(fs.getWorkingDirectory, "outdir")
117+
SparkHadoopUtil.get.getFSBytesWrittenOnThreadCallback(outPath, fs.getConf)
118+
119+
// Intentionally call this method with a null scheme, which will store an entry for a FileSystem
120+
// with a null scheme into Hadoop's global `FileSystem.statisticsTable`.
121+
FileSystem.getStatistics(null, classOf[FileSystem])
122+
123+
// Prior to fixing SPARK-8062, this would fail with a NullPointerException in
124+
// SparkHadoopUtil.getFileSystemThreadStatistics
125+
val rdd = sc.parallelize(Array("a", "b", "c", "d"), 2)
126+
try {
127+
rdd.saveAsTextFile(outPath.toString)
128+
sc.textFile(outPath.toString).count()
129+
} finally {
130+
fs.delete(outPath, true)
131+
}
132+
}
109133
}

0 commit comments

Comments
 (0)