Bug #103806 CJCommunicationsException is not recoverable
Submitted: 26 May 2021 2:29 Modified: 27 May 2021 11:36
Reporter: liang Fanl Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S7 (Test Cases)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[26 May 2021 2:29] liang Fanl
Description:
in the implementation of com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping#translateException(java.lang.Throwable, com.mysql.cj.exceptions.ExceptionInterceptor), CJCommunicationsException is converted to CommunicationsException, which is a subclass of SQLRecoverableException. this is not appropriate, we faced a situation when a failover happens, application keeps trying to use old connection, but the old primary node is already down.

How to repeat:
testsuite.x.devapi.SessionTest#testConnectionCloseNotification covers this situation, CJCommunicationsException is thrown as expected when server shutdown, but the later handle is not appropriate

Suggested fix:
have not idea
[27 May 2021 10:59] Filipe Silva
Hi liang Fanl,

As stated in the API documentation for SQLRecoverableException:

> At a minimum, the recovery operation must include closing the current connection and getting a new connection.

So, why does your application keep trying the old connection?

Also, the "how to repeat" you pointed out refers to X DevAPI, which has nothing to do with JDBC so you can't compare them with this regard.

Please clarify what exaclty is happening in your application and how you are using Connector/J, as well as what are your expectations, so that we may be able to help you.
[27 May 2021 11:36] liang Fanl
sorry for the misunderstanding and wrong handeling of SQLRecoverableException, i'll close this ticket