Skip to content

Comments

Add a closing method with timeout for JDBC connection #5111

Closed
bowenliang123 wants to merge 2 commits intoapache:masterfrom
bowenliang123:connection-close
Closed

Add a closing method with timeout for JDBC connection #5111
bowenliang123 wants to merge 2 commits intoapache:masterfrom
bowenliang123:connection-close

Conversation

@bowenliang123
Copy link
Contributor

@bowenliang123 bowenliang123 commented Jul 31, 2023

Why are the changes needed?

  • add the method in KyuubiConnection for forcibly closing the connection with timeout
  • to get rid of the jammed situation on the client side, and making sure of destorying instance of transport and client

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

@bowenliang123 bowenliang123 changed the title add the method for closing the connection within timeout forcibly add closing method with timeout for JDBC connection Jul 31, 2023
@bowenliang123 bowenliang123 changed the title add closing method with timeout for JDBC connection Add closing method with timeout for JDBC connection Jul 31, 2023
@bowenliang123 bowenliang123 changed the title Add closing method with timeout for JDBC connection Add a closing method with timeout for JDBC connection Jul 31, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #5111 (1043350) into master (998b5d5) will not change coverage.
Report is 1 commits behind head on master.
The diff coverage is 0.00%.

@@          Coverage Diff           @@
##           master   #5111   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files         564     564           
  Lines       31293   31313   +20     
  Branches     4095    4096    +1     
======================================
- Misses      31293   31313   +20     
Files Changed Coverage Δ
.../org/apache/kyuubi/jdbc/hive/KyuubiConnection.java 0.00% <0.00%> (ø)

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

@bowenliang123 bowenliang123 marked this pull request as ready for review July 31, 2023 09:48
@bowenliang123
Copy link
Contributor Author

cc @jeanlyn

@bowenliang123 bowenliang123 requested a review from pan3793 July 31, 2023 10:20
} catch (Exception e) {
LOG.error("Error while closing connection with in timeout", e);
} finally {
executor.shutdownNow();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it works, the body of runWithTimeout runs in another thread, which means the current thread would reach this line soon.

BTW, I don't think we should add such a method at the JDBC driver level, it's the caller's responsibility to cancel after a certain time.

Copy link
Contributor Author

@bowenliang123 bowenliang123 Aug 1, 2023

Choose a reason for hiding this comment

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

Once we abandoned a jammed JDBC connection on client side, we want to release and destroy the connection and the member instances inside the connection, like the transport and the client. How to achieve that? And what's cancel for a JDBC connection?

Copy link
Member

@pan3793 pan3793 Aug 1, 2023

Choose a reason for hiding this comment

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

Once we abandoned a jammed JDBC connection on client side, we want to release and destroy the connection and the member instances inside the connection, like the transport and the client. How to achieve that?

Abandon the whole Connection instance, and make sure to call Connection#close before losing reference.

And what's cancel for a JDBC connection?

typo, I mean close

Copy link
Contributor Author

@bowenliang123 bowenliang123 Aug 1, 2023

Choose a reason for hiding this comment

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

Or let's add a dedicated method for closing transport inside the KyuubiConnection , in my case for forcibly destroying the instance of TTransport and TCLIService inside?

@bowenliang123 bowenliang123 deleted the connection-close branch August 15, 2023 00:42
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.

3 participants