SoWhat-ET opened a new issue, #7478:
URL: https://github.com/apache/paimon/issues/7478

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/paimon/issues) 
and found nothing similar.
   
   
   ### Paimon version
   
   Paimon: 1.3.1 (or earlier versions, as long as JdbcClientPool behavior is 
consistent)
   MySQL Connector/J: 8.0+
   MySQL Server: 5.7+ (likely all versions are affected by wait_timeout)
   
   ### Compute Engine
   
   Flink 1.20.3 FlinkCDC 3.5.0
   
   ### Minimal reproduce step
   
   1. Configure a Paimon JDBC Catalog to connect to a MySQL database.
   2. Run a Flink CDC job that intermittently writes data to a Paimon table.
   3. Allow the job to run for some time, ensuring connections remain idle for 
an extended period.
   4. When Paimon attempts to reuse these long-idle connections, a 
CommunicationsException will be thrown.
   
   ### What doesn't meet your expectations?
   
   Description:
   
   When using Paimon 1.3.1's JDBC Catalog as a target for Flink CDC, we have 
encountered intermittent MySQL connection timeout issues, manifested as 
CommunicationsException: Communications link failure. This problem typically 
occurs when a connection that has been idle for an extended period is 
subsequently reused.
   
   Problem Analysis:
   
   Paimon JdbcClientPool Lacks Connection Liveness Check:
   Paimon's JdbcClientPool is a simplified connection pool implementation. It 
does not perform liveness checks on connections (e.g., validationQuery) before 
they are retrieved from the pool. This means the pool might return a "dead" 
connection that has already been terminated by the MySQL server.
   
   MySQL wait_timeout Causes Connection Termination:
   The MySQL server has wait_timeout and interactive_timeout parameters. If a 
connection remains inactive for longer than the configured duration (defaulting 
to 28800 seconds, or 8 hours), the MySQL server will actively terminate it.
   
   autoReconnect Parameter is Ineffective:
   In MySQL Connector/J 8.0 and higher versions, the autoReconnect parameter is 
deprecated and no longer effective. Therefore, configuring autoReconnect=true 
in the JDBC URL does not resolve this issue.
   
   SHOW PROCESSLIST Evidence:
   Observations from MySQL's SHOW PROCESSLIST output show numerous connections 
in the Sleep state, with their Time field often approaching or exceeding the 
wait_timeout setting. This confirms that connections are being terminated by 
the server due to prolonged idleness.
   
   ### Anything else?
   
   Suggested Workaround:
   
   The most effective temporary solution is to increase the values of 
wait_timeout and interactive_timeout on the MySQL server-side. For example, 
setting them to 86400 seconds (24 hours) or higher can prevent MySQL from 
actively terminating connections prematurely, matching the potential idle times 
of Flink CDC jobs.
   
   Paimon Community Recommendations:
   
   Consider enhancing Paimon's JdbcClientPool with more robust connection 
management mechanisms, including but not limited to:
   
   Connection Liveness Probes: Implement an optional connection validation 
logic (e.g., executing a lightweight SELECT 1 query) when retrieving 
connections from the pool.
   Enhanced Pool Configuration: Allow users to configure parameters like 
idleTimeout or maxLifeTime, enabling the connection pool to proactively close 
or replace idle or expiring connections.
   Upgrade Connection Pool Implementation: Consider integrating or utilizing 
mature industry-standard JDBC connection pool libraries (e.g., HikariCP, 
Druid), which typically offer comprehensive connection management and fault 
recovery features.
   Unrecommended Attempts:
   
   Increasing client-pool-size in the Paimon JDBC Catalog configuration. This 
will only create more potentially stale connections and exacerbate the problem.
   Setting validationQuery or autoReconnect in jdbc.properties.*, as Paimon's 
JdbcClientPool does not support these parameters, and autoReconnect is 
ineffective in newer driver versions.
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
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]

Reply via email to