morozov commented on code in PR #3666:
URL: https://github.com/apache/flink-cdc/pull/3666#discussion_r2129396299
##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/io/debezium/connector/mysql/MySqlConnection.java:
##########
@@ -90,6 +94,40 @@ public MySqlConnection(
this.connectionConfig = connectionConfig;
this.mysqlFieldReader = fieldReader;
this.urlPattern = connectionConfig.getUrlPattern();
+
+ probeShowBinaryLogStatement();
+ }
+
+ public String probeShowBinaryLogStatement() {
+ if (showBinaryLogStatement != null) {
+ return showBinaryLogStatement;
+ }
+ try {
+ LOGGER.info("Probing binary log statement.");
+ try {
+ // Attempt to query
+ query(MYSQL_NEW_SHOW_BINARY_LOG_STATEMENT, rs -> {});
+ showBinaryLogStatement = MYSQL_NEW_SHOW_BINARY_LOG_STATEMENT;
+ } catch (SQLException e) {
+ LOGGER.info(
+ "Probing with {} failed, try {}. Caused by: {}",
+ MYSQL_NEW_SHOW_BINARY_LOG_STATEMENT,
+ MYSQL_CLASSIC_SHOW_BINARY_LOG_STATEMENT,
+ e);
+ query(MYSQL_CLASSIC_SHOW_BINARY_LOG_STATEMENT, rs -> {});
Review Comment:
If we're going to fall back to this statement anyways, why probe it? The
corresponding
[code](https://github.com/debezium/debezium/blob/8ca8f451f85c6674f37fc1c1d899a4b556b69553/debezium-connector-mysql/src/main/java/io/debezium/connector/mysql/jdbc/MySqlConnection.java#L36-L47)
in Debezium looks simpler.
##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/io/debezium/connector/mysql/MySqlConnection.java:
##########
@@ -90,6 +95,41 @@ public MySqlConnection(
this.connectionConfig = connectionConfig;
this.mysqlFieldReader = fieldReader;
this.urlPattern = connectionConfig.getUrlPattern();
+
+ probeShowBinaryLogStatement();
Review Comment:
This call probes the statement but doesn't store the result. Should it
assign it to `showBinaryLogStatement`? In this case, the field can be made
final.
##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/io/debezium/connector/mysql/MySqlConnection.java:
##########
@@ -90,6 +94,40 @@ public MySqlConnection(
this.connectionConfig = connectionConfig;
this.mysqlFieldReader = fieldReader;
this.urlPattern = connectionConfig.getUrlPattern();
+
+ probeShowBinaryLogStatement();
+ }
+
+ public String probeShowBinaryLogStatement() {
+ if (showBinaryLogStatement != null) {
+ return showBinaryLogStatement;
+ }
+ try {
+ LOGGER.info("Probing binary log statement.");
+ try {
+ // Attempt to query
+ query(MYSQL_NEW_SHOW_BINARY_LOG_STATEMENT, rs -> {});
+ showBinaryLogStatement = MYSQL_NEW_SHOW_BINARY_LOG_STATEMENT;
+ } catch (SQLException e) {
+ LOGGER.info(
+ "Probing with {} failed, try {}. Caused by: {}",
+ MYSQL_NEW_SHOW_BINARY_LOG_STATEMENT,
+ MYSQL_CLASSIC_SHOW_BINARY_LOG_STATEMENT,
+ e);
Review Comment:
Would it be sufficient to just log the exception message? It isn't an error,
so someone looking at the logs may see a stack trace, think that there is some
problem, but in fact there is none.
--
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]