Skip to content

Commit

Permalink
[KYUUBI #2227] Fix operation log dir not deleted issue
Browse files Browse the repository at this point in the history
### _Why are the changes needed?_

Refer: #2208 (comment)

To close #2227

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #2229 from turboFei/delete_log.

Closes #2227

bf7efca [Fei Wang] delete log dir with recurisive

Authored-by: Fei Wang <fwang12@ebay.com>
Signed-off-by: Fei Wang <fwang12@ebay.com>
  • Loading branch information
turboFei committed Mar 27, 2022
1 parent c1ffc3c commit 55052f9
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import scala.collection.JavaConverters._

import org.apache.hive.service.rpc.thrift.TProtocolVersion

import org.apache.kyuubi.KyuubiSQLException
import org.apache.kyuubi.{KyuubiSQLException, Utils}
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.config.KyuubiConf._
import org.apache.kyuubi.operation.OperationManager
Expand Down Expand Up @@ -89,16 +89,16 @@ abstract class SessionManager(name: String) extends CompositeService(name) {
if (session == null) {
throw KyuubiSQLException(s"Invalid $sessionHandle")
}
deleteOperationLogSessionDir(sessionHandle)
info(s"$sessionHandle is closed, current opening sessions $getOpenSessionCount")
session.close()
deleteOperationLogSessionDir(sessionHandle)
}

private def deleteOperationLogSessionDir(sessionHandle: SessionHandle): Unit = {
_operationLogRoot.foreach(logRoot => {
val rootPath = Paths.get(logRoot, sessionHandle.identifier.toString)
try {
Files.deleteIfExists(rootPath)
Utils.deleteDirectoryRecursively(rootPath.toFile)
} catch {
case e: IOException =>
error(s"Failed to delete session operation log directory ${rootPath.toString}", e)
Expand Down

0 comments on commit 55052f9

Please sign in to comment.