Bug #82500 abortInternal() will mark isClose true, but not close cancelTimer
Submitted: 9 Aug 2016 7:58 Modified: 24 Feb 2022 12:22
Reporter: leo leo Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.31 OS:Any
Assigned to: Filipe Silva CPU Architecture:Any
Tags: abortInternal(), cancelTimer, isValid()

[9 Aug 2016 7:58] leo leo
Description:
when JDBC4Connection call isValid(), if pingInternal() failed, then will excute abortInternal(), and isClosed will be set true in this method. but when excute realClose(), if isClosed equals true, it will return and not cancel cancelTimer.

How to repeat:
1. setQueryTimeout to make sure that cancelTimmer is started.
2. server close connection.
3. client use this connection and use isValid to check if connection is alive or not. 

Suggested fix:
maybe we can close cancelTimer before set isClosed true in abortInternal()
[9 Aug 2016 12:17] Chiranjeevi Battula
Hello leo,

Thank you for the bug report.
Verified based on internal discussion with dev's.

Thanks,
Chiranjeevi.
[14 Sep 2016 18:43] Filipe Silva
Hi Leo,

I don't fully understand your report. Are you saying that you are observing a thread leakage when query timeouts are set and the connections break? Do you have a reproducible test case for this?

You see, the cancelTimer thread only exists while a query is being executed. If for some reason the connection is closed on the server, then the client immediately interrupts waiting for the server response and in the process of dealing with the connection failure it cancels the cancel timer. So, as per your "how to repeat" steps, when you call the method isValid() there shouldn't be any canceling thread.

Can you provide more details please? Desirably a reproducible test case.
[15 Oct 2016 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[24 Feb 2022 12:22] Alexander Soklakov
Posted by developer:
 
This bug is irrelevant to the latest Connector/J 8.0 code.

Connector/J 5.1 series came to EOL on Feb 9th, 2021, see https://www.mysql.com/support/eol-notice.html, so this bug will not be fixed there.