Skip to content

Conversation

@ulysses-you
Copy link
Contributor

@ulysses-you ulysses-you commented Feb 3, 2023

Why are the changes needed?

We do not need force close engine builder and application if open session succeded. The engine itself will shutdown in connection level.

This pr tries to fix regression of #2482

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 locally before make a pull request

@codecov-commenter
Copy link

Codecov Report

Merging #4241 (0b28041) into master (62eefdb) will decrease coverage by 0.11%.
The diff coverage is 33.33%.

@@             Coverage Diff              @@
##             master    #4241      +/-   ##
============================================
- Coverage     53.59%   53.48%   -0.11%     
  Complexity       13       13              
============================================
  Files           560      560              
  Lines         30422    30420       -2     
  Branches       4084     4081       -3     
============================================
- Hits          16304    16270      -34     
- Misses        12614    12645      +31     
- Partials       1504     1505       +1     
Impacted Files Coverage Δ
.../org/apache/kyuubi/session/KyuubiSessionImpl.scala 75.67% <33.33%> (-1.04%) ⬇️
...e/kyuubi/jdbc/hive/ClosedOrCancelledException.java 0.00% <0.00%> (-100.00%) ⬇️
.../kyuubi/server/mysql/constant/MySQLErrorCode.scala 13.84% <0.00%> (-6.16%) ⬇️
...ache/kyuubi/server/mysql/MySQLCommandHandler.scala 77.77% <0.00%> (-4.05%) ⬇️
...ain/scala/org/apache/kyuubi/engine/EngineRef.scala 71.42% <0.00%> (-3.18%) ⬇️
.../apache/kyuubi/server/api/v1/BatchesResource.scala 70.09% <0.00%> (-2.81%) ⬇️
...ache/kyuubi/server/mysql/MySQLGenericPackets.scala 76.59% <0.00%> (-2.13%) ⬇️
...n/scala/org/apache/kyuubi/engine/ProcBuilder.scala 79.01% <0.00%> (-1.86%) ⬇️
...g/apache/kyuubi/operation/BatchJobSubmission.scala 75.27% <0.00%> (-1.70%) ⬇️
...rg/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala 59.09% <0.00%> (-1.52%) ⬇️
... and 6 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@pan3793 pan3793 requested a review from wForget February 3, 2023 11:15
if (_client != null) _client.closeSession()
} finally {
if (engine != null) engine.close()
openSessionError.foreach { _ => if (engine != null) engine.close() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The egine will not be reused if the sharelevel is a CONNECTION and the session is closed, so should close engine whether open session fails or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With connection share level, engine should close gracefully by itself. Engine exit code will not be 0 if we close engine by Kyuubi Server.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a timeout to wait for the engine status to complete, and then kill the application.

Copy link
Contributor Author

@ulysses-you ulysses-you Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, but it's a bit complex. I think this pr is enough to fix regression.

I see your requreiements that to avoid the leaked engine. We can improve that in a global view rather than wait and kill one by one. e.g. Use a thread to detect if there is a leaked engine.

Note, it's the key to define what is the leaked engine. In general, A leaked engine can be:

  • status is finished in resource manager but engine build process is alive (for all share level)
  • session is closed but status is not fiinshed or engine build process is alive (for connection share level and batch mode)

We can have a new pr if you are interested in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, but it's a bit complex. I think this pr is enough to fix regression.

I see your requreiements that to avoid the leaked engine. We can improve that in a global view rather than wait and kill one by one. e.g. Use a thread to detect if there is a leaked engine.

Note, it's the key to define what is the leaked engine. In general, A leaked engine can be:

  • status is finished in resource manager but engine build process is alive (for all share level)
  • session is closed but status is not fiinshed or engine build process is alive (for connection share level and batch mode)

We can have a new pr if you are interested in.

I agree with you, this pr is enough to fix the previous issue.

@ulysses-you
Copy link
Contributor Author

ulysses-you commented Feb 6, 2023

thanks for review, merging to master/branch-1.6

ulysses-you added a commit that referenced this pull request Feb 6, 2023
We do not need force close engine builder and application if open session succeded. The engine itself will shutdown in connection level.

This pr tries to fix regression of #2482

- [ ] 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.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #4241 from ulysses-you/skip-close.

Closes #4241

0b28041 [ulysses-you] style
1636912 [ulysses-you] Only force close engine ref when open session failed

Authored-by: ulysses-you <ulyssesyou18@gmail.com>
Signed-off-by: ulyssesyou <ulyssesyou@apache.org>
(cherry picked from commit 8760eee)
Signed-off-by: ulyssesyou <ulyssesyou@apache.org>
@ulysses-you ulysses-you deleted the skip-close branch February 6, 2023 03:16
@pan3793 pan3793 added this to the v1.6.2 milestone Feb 6, 2023
pan3793 added a commit that referenced this pull request Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants