This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch branch-1.8
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.8 by this push:
new e01b86519 [KYUUBI #5391] Close batch session after batch operation
completion for idle timeout
e01b86519 is described below
commit e01b865199e464d1f4ac525b7e29b661d8aeffff
Author: fwang12 <[email protected]>
AuthorDate: Tue Oct 10 16:40:42 2023 +0800
[KYUUBI #5391] Close batch session after batch operation completion for
idle timeout
### _Why are the changes needed?_
To add a limitation for batch session lifecycle. otherwise, the batch
session might always alive.
### _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
- [x] [Run
test](https://kyuubi.readthedocs.io/en/master/contributing/code/testing.html#running-tests)
locally before make a pull request
### _Was this patch authored or co-authored using generative AI tooling?_
No.
Closes #5391 from turboFei/close_session_with_maxtimeout.
Closes #5391
5639c7d6b [fwang12] session no op
Authored-by: fwang12 <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
(cherry picked from commit e1d213ee9961a706cad47a263211ca8cb2c9057f)
Signed-off-by: Cheng Pan <[email protected]>
---
.../scala/org/apache/kyuubi/session/KyuubiBatchSession.scala | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git
a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSession.scala
b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSession.scala
index e10230ebf..8e4c5137f 100644
---
a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSession.scala
+++
b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSession.scala
@@ -61,9 +61,13 @@ class KyuubiBatchSession(
override def createTime: Long =
metadata.map(_.createTime).getOrElse(super.createTime)
override def getNoOperationTime: Long = {
- if (batchJobSubmissionOp != null && !OperationState.isTerminal(
- batchJobSubmissionOp.getStatus.state)) {
- 0L
+ if (batchJobSubmissionOp != null) {
+ val batchStatus = batchJobSubmissionOp.getStatus
+ if (!OperationState.isTerminal(batchStatus.state)) {
+ 0L
+ } else {
+ System.currentTimeMillis() - batchStatus.completed
+ }
} else {
super.getNoOperationTime
}