Skip to content

Commit b7a8199

Browse files
mgaido91cloud-fan
authored andcommitted
[SPARK-23089][STS] Recreate session log directory if it doesn't exist
## What changes were proposed in this pull request? When creating a session directory, Thrift should create the parent directory (i.e. /tmp/base_session_log_dir) if it is not present. It is common that many tools delete empty directories, so the directory may be deleted. This can cause the session log to be disabled. This was fixed in HIVE-12262: this PR brings it in Spark too. ## How was this patch tested? manual tests Author: Marco Gaido <[email protected]> Closes #20281 from mgaido91/SPARK-23089. (cherry picked from commit e41400c) Signed-off-by: Wenchen Fan <[email protected]>
1 parent ef7989d commit b7a8199

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/session/HiveSessionImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,18 @@ private void configureSession(Map<String, String> sessionConfMap) throws HiveSQL
223223

224224
@Override
225225
public void setOperationLogSessionDir(File operationLogRootDir) {
226+
if (!operationLogRootDir.exists()) {
227+
LOG.warn("The operation log root directory is removed, recreating: " +
228+
operationLogRootDir.getAbsolutePath());
229+
if (!operationLogRootDir.mkdirs()) {
230+
LOG.warn("Unable to create operation log root directory: " +
231+
operationLogRootDir.getAbsolutePath());
232+
}
233+
}
234+
if (!operationLogRootDir.canWrite()) {
235+
LOG.warn("The operation log root directory is not writable: " +
236+
operationLogRootDir.getAbsolutePath());
237+
}
226238
sessionLogDir = new File(operationLogRootDir, sessionHandle.getHandleIdentifier().toString());
227239
isOperationLogEnabled = true;
228240
if (!sessionLogDir.exists()) {

0 commit comments

Comments
 (0)