pan3793 opened a new pull request, #7876:
URL: https://github.com/apache/kyuubi/pull/7876

   ### Why are the changes needed?
   
   Currently, `kyuubi.session.idle.timeout` also takes effect while an 
interactive session is launching its backend engine.
   
   When `SessionManager.openSession` registers a `KyuubiSessionImpl`, both 
`lastAccessTime` and `lastIdleTime` are initialized to `createTime`. 
`KyuubiSessionImpl.open()` runs `launchEngineOp` without 
`withAcquireRelease()`, leaving `lastIdleTime` non-zero. If engine startup 
waits longer than `kyuubi.session.idle.timeout` (for example, pending YARN 
container allocation while still within 
`kyuubi.session.engine.initialize.timeout`), `SessionManager`'s timeout checker 
treats the session as idle and closes it, causing the job to fail. This affects 
both synchronous and asynchronous engine launch modes.
   
   This patch overrides `KyuubiSessionImpl.getNoOperationTime` to:
   
   1. Return `0L` while `launchEngineOp` is in a non-terminal state, so engine 
startup timeout is governed solely by 
`kyuubi.session.engine.initialize.timeout`.
   2. Measure idle time from `math.max(lastIdleTime, 
launchEngineOp.getCompletedTime)` once `launchEngineOp` reaches a terminal 
state, avoiding immediate timeout after a long engine launch while still 
cleaning up idle or failed sessions.
   3. Read `launchEngineOp`'s `state` and `completedTime` without calling 
`getStatus`, so `launchEngineOp.lastAccessTime` is not refreshed and operation 
idle expiration remains unaffected.
   
   ### How was this patch tested?
   
   Added unit tests in `KyuubiSessionIdleTimeoutSuite`:
   
   1. Async engine launch exceeding `kyuubi.session.idle.timeout` is not closed 
during launch or immediately after completion, and is closed once idle timeout 
elapses post-launch.
   2. Sync engine launch exceeding `kyuubi.session.idle.timeout` is not closed 
during launch and completes normally.
   3. Failed async engine launch session is closed after 
`kyuubi.session.idle.timeout`.
   
   Verified with:
   
   ```bash
   dev/reformat
   build/mvn spotless:check scalastyle:check test 
-Pspark-provided,flink-provided,hive-provided   -pl kyuubi-server -am 
-Dtest=none   
-DwildcardSuites=org.apache.kyuubi.session.KyuubiSessionIdleTimeoutSuite
   ```
   
   ### Was this patch assisted by generative AI tooling?
   
   Assisted-by: DeepSeek Harness with Gemini 4 Neon


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to