Skip to content

Commit 0ea46ac

Browse files
sarutakmarmbrus
authored andcommitted
[SPARK-3062] [SPARK-2970] [SQL] spark-sql script ends with IOException when EventLogging is enabled
apache#1891 was to avoid IOException when EventLogging is enabled. The solution used ShutdownHookManager but it was defined only Hadoop 2.x. Hadoop 1.x don't have ShutdownHookManager so apache#1891 doesn't compile on Hadoop 1.x Now, I had a compromised solution for both Hadoop 1.x and 2.x. Only for FileLogger, an unique FileSystem object is created. Author: Kousuke Saruta <[email protected]> Closes apache#1970 from sarutak/SPARK-2970 and squashes the following commits: 240c91e [Kousuke Saruta] Merge branch 'master' of git://git.apache.org/spark into SPARK-2970 0e7b45d [Kousuke Saruta] Revert "[SPARK-2970] [SQL] spark-sql script ends with IOException when EventLogging is enabled" e1262ec [Kousuke Saruta] Modified Filelogger to use unique FileSystem instance
1 parent cf46e72 commit 0ea46ac

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

core/src/main/scala/org/apache/spark/util/FileLogger.scala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,20 @@ private[spark] class FileLogger(
5252
override def initialValue(): SimpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")
5353
}
5454

55-
private val fileSystem = Utils.getHadoopFileSystem(logDir)
55+
/**
56+
* To avoid effects of FileSystem#close or FileSystem.closeAll called from other modules,
57+
* create unique FileSystem instance only for FileLogger
58+
*/
59+
private val fileSystem = {
60+
val conf = SparkHadoopUtil.get.newConfiguration()
61+
val logUri = new URI(logDir)
62+
val scheme = logUri.getScheme
63+
if (scheme == "hdfs") {
64+
conf.setBoolean("fs.hdfs.impl.disable.cache", true)
65+
}
66+
FileSystem.get(logUri, conf)
67+
}
68+
5669
var fileIndex = 0
5770

5871
// Only used if compression is enabled

0 commit comments

Comments
 (0)