This is an automated email from the ASF dual-hosted git repository. leonard pushed a commit to branch release-3.1 in repository https://gitbox.apache.org/repos/asf/flink-cdc.git
The following commit(s) were added to refs/heads/release-3.1 by this push: new 84ae0dc45 [FLINK-35301][cdc] Avoid deadlock when loading driver classes 84ae0dc45 is described below commit 84ae0dc45349f19175552a9dbcbfd2f296cfc56a Author: yux <34335406+yuxiq...@users.noreply.github.com> AuthorDate: Mon Jun 3 16:30:24 2024 +0800 [FLINK-35301][cdc] Avoid deadlock when loading driver classes This closes #3372. --- .../base/relational/connection/JdbcConnectionPoolFactory.java | 3 +++ .../src/main/java/io/debezium/connector/mysql/MySqlConnection.java | 2 ++ .../connectors/mysql/source/connection/PooledDataSourceFactory.java | 2 ++ 3 files changed, 7 insertions(+) diff --git a/flink-cdc-connect/flink-cdc-source-connectors/flink-cdc-base/src/main/java/org/apache/flink/cdc/connectors/base/relational/connection/JdbcConnectionPoolFactory.java b/flink-cdc-connect/flink-cdc-source-connectors/flink-cdc-base/src/main/java/org/apache/flink/cdc/connectors/base/relational/connection/JdbcConnectionPoolFactory.java index 2049b571d..4ea8ea526 100644 --- a/flink-cdc-connect/flink-cdc-source-connectors/flink-cdc-base/src/main/java/org/apache/flink/cdc/connectors/base/relational/connection/JdbcConnectionPoolFactory.java +++ b/flink-cdc-connect/flink-cdc-source-connectors/flink-cdc-base/src/main/java/org/apache/flink/cdc/connectors/base/relational/connection/JdbcConnectionPoolFactory.java @@ -23,6 +23,8 @@ import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import io.debezium.jdbc.JdbcConfiguration; +import java.sql.DriverManager; + /** A connection pool factory to create pooled DataSource {@link HikariDataSource}. */ public abstract class JdbcConnectionPoolFactory { @@ -43,6 +45,7 @@ public abstract class JdbcConnectionPoolFactory { config.setMinimumIdle(MINIMUM_POOL_SIZE); config.setMaximumPoolSize(sourceConfig.getConnectionPoolSize()); config.setConnectionTimeout(sourceConfig.getConnectTimeout().toMillis()); + DriverManager.getDrivers(); config.setDriverClassName(sourceConfig.getDriverClassName()); // note: the following properties should be optional (only applied to MySQL) diff --git a/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/io/debezium/connector/mysql/MySqlConnection.java b/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/io/debezium/connector/mysql/MySqlConnection.java index 84f5c230a..801e27d6b 100644 --- a/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/io/debezium/connector/mysql/MySqlConnection.java +++ b/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/io/debezium/connector/mysql/MySqlConnection.java @@ -26,6 +26,7 @@ import io.debezium.util.Strings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.time.Duration; @@ -622,6 +623,7 @@ public class MySqlConnection extends JdbcConnection { this.jdbcConfig = JdbcConfiguration.adapt(jdbcConfigBuilder.build()); String driverClassName = this.jdbcConfig.getString(MySqlConnectorConfig.JDBC_DRIVER); this.urlPattern = formatJdbcUrl(jdbcProperties); + DriverManager.getDrivers(); factory = JdbcConnection.patternBasedFactory( urlPattern, driverClassName, getClass().getClassLoader()); diff --git a/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/connection/PooledDataSourceFactory.java b/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/connection/PooledDataSourceFactory.java index 14ec7cd8b..e5f6bcd37 100644 --- a/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/connection/PooledDataSourceFactory.java +++ b/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/connection/PooledDataSourceFactory.java @@ -25,6 +25,7 @@ import com.zaxxer.hikari.HikariDataSource; import com.zaxxer.hikari.pool.HikariPool; import io.debezium.connector.mysql.MySqlConnectorConfig; +import java.sql.DriverManager; import java.util.Properties; /** A connection pool factory to create pooled DataSource {@link HikariDataSource}. */ @@ -54,6 +55,7 @@ public class PooledDataSourceFactory { config.setMaximumPoolSize(sourceConfig.getConnectionPoolSize()); config.setConnectionTimeout(sourceConfig.getConnectTimeout().toMillis()); config.addDataSourceProperty(SERVER_TIMEZONE_KEY, sourceConfig.getServerTimeZone()); + DriverManager.getDrivers(); config.setDriverClassName( sourceConfig.getDbzConfiguration().getString(MySqlConnectorConfig.JDBC_DRIVER));