Skip to content

Commit 905dc4b

Browse files
sarutakmarmbrus
authored andcommitted
[SPARK-2970] [SQL] spark-sql script ends with IOException when EventLogging is enabled
Author: Kousuke Saruta <[email protected]> Closes #1891 from sarutak/SPARK-2970 and squashes the following commits: 4a2d2fe [Kousuke Saruta] Modified comment style 8bd833c [Kousuke Saruta] Modified style 6c0997c [Kousuke Saruta] Modified the timing of shutdown hook execution. It should be executed before shutdown hook of o.a.h.f.FileSystem
1 parent 9fde1ff commit 905dc4b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkSQLCLIDriver.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import jline.{ConsoleReader, History}
2626
import org.apache.commons.lang.StringUtils
2727
import org.apache.commons.logging.LogFactory
2828
import org.apache.hadoop.conf.Configuration
29+
import org.apache.hadoop.fs.FileSystem
30+
import org.apache.hadoop.util.ShutdownHookManager
2931
import org.apache.hadoop.hive.cli.{CliDriver, CliSessionState, OptionsProcessor}
3032
import org.apache.hadoop.hive.common.LogUtils.LogInitializationException
3133
import org.apache.hadoop.hive.common.{HiveInterruptCallback, HiveInterruptUtils, LogUtils}
@@ -116,13 +118,17 @@ private[hive] object SparkSQLCLIDriver {
116118
SessionState.start(sessionState)
117119

118120
// Clean up after we exit
119-
Runtime.getRuntime.addShutdownHook(
121+
/**
122+
* This should be executed before shutdown hook of
123+
* FileSystem to avoid race condition of FileSystem operation
124+
*/
125+
ShutdownHookManager.get.addShutdownHook(
120126
new Thread() {
121127
override def run() {
122128
SparkSQLEnv.stop()
123129
}
124130
}
125-
)
131+
, FileSystem.SHUTDOWN_HOOK_PRIORITY - 1)
126132

127133
// "-h" option has been passed, so connect to Hive thrift server.
128134
if (sessionState.getHost != null) {

0 commit comments

Comments
 (0)