ruanhang1993 commented on code in PR #3148:
URL: https://github.com/apache/flink-cdc/pull/3148#discussion_r1560376062


##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/MySqlValidator.java:
##########
@@ -50,6 +50,7 @@ public class MySqlValidator implements Validator {
 
     private static final String BINLOG_FORMAT_ROW = "ROW";
     private static final String BINLOG_FORMAT_IMAGE_FULL = "FULL";
+    private static final String BINLOG_ROW_VALUE_OPTIONS = "";

Review Comment:
   ```suggestion
       private static final String DEFAULT_BINLOG_ROW_VALUE_OPTIONS = "";
   ```



##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/MySqlValidator.java:
##########
@@ -159,6 +161,27 @@ private void checkBinlogRowImage(JdbcConnection 
connection) throws SQLException
         }
     }
 
+    /** Check whether the binlog row value options is empty. */
+    private void checkBinlogRowValueOptions(JdbcConnection connection) throws 
SQLException {
+        String rowValueOptions =
+                connection
+                        .queryAndMap(
+                                "SHOW GLOBAL VARIABLES LIKE 
'binlog_row_value_options'",
+                                rs -> rs.next() ? rs.getString(2) : "")
+                        .trim()
+                        .toUpperCase();
+        // This setting was introduced in MySQL 8.0+ with default of empty 
string ''
+        // For older versions, assume empty string ''
+        if (!rowValueOptions.equals(BINLOG_ROW_VALUE_OPTIONS)) {

Review Comment:
   ```suggestion
           if (!BINLOG_ROW_VALUE_OPTIONS.equals(rowValueOptions)) {
   ```



##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/MySqlValidator.java:
##########
@@ -159,6 +161,27 @@ private void checkBinlogRowImage(JdbcConnection 
connection) throws SQLException
         }
     }
 
+    /** Check whether the binlog row value options is empty. */
+    private void checkBinlogRowValueOptions(JdbcConnection connection) throws 
SQLException {
+        String rowValueOptions =
+                connection
+                        .queryAndMap(
+                                "SHOW GLOBAL VARIABLES LIKE 
'binlog_row_value_options'",
+                                rs -> rs.next() ? rs.getString(2) : "")
+                        .trim()
+                        .toUpperCase();
+        // This setting was introduced in MySQL 8.0+ with default of empty 
string ''
+        // For older versions, assume empty string ''
+        if (!rowValueOptions.equals(BINLOG_ROW_VALUE_OPTIONS)) {
+            throw new ValidationException(
+                    String.format(
+                            "The MySQL server is configured with 
binlog_row_value_options=%s, which is possible to cause losing some binlog 
events"
+                                    + "for the mysql cdc connector. Please 
remove the binlog_row_value_options setting in the MySQL server and rerun the 
job."
+                                    + "See more details at 
https://dev.mysql.com/doc/refman/8.0/en/replication-features-json.html.";,
+                            rowValueOptions, BINLOG_ROW_VALUE_OPTIONS));

Review Comment:
   ```suggestion
                               rowValueOptions));
   ```



##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/MySqlValidator.java:
##########
@@ -159,6 +161,27 @@ private void checkBinlogRowImage(JdbcConnection 
connection) throws SQLException
         }
     }
 
+    /** Check whether the binlog row value options is empty. */
+    private void checkBinlogRowValueOptions(JdbcConnection connection) throws 
SQLException {
+        String rowValueOptions =
+                connection
+                        .queryAndMap(
+                                "SHOW GLOBAL VARIABLES LIKE 
'binlog_row_value_options'",
+                                rs -> rs.next() ? rs.getString(2) : "")

Review Comment:
   ```suggestion
                                   rs -> rs.next() ? rs.getString(2) : 
DEFAULT_BINLOG_ROW_VALUE_OPTIONS)
   ```



##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/MySqlValidator.java:
##########
@@ -159,6 +161,27 @@ private void checkBinlogRowImage(JdbcConnection 
connection) throws SQLException
         }
     }
 
+    /** Check whether the binlog row value options is empty. */
+    private void checkBinlogRowValueOptions(JdbcConnection connection) throws 
SQLException {
+        String rowValueOptions =
+                connection
+                        .queryAndMap(
+                                "SHOW GLOBAL VARIABLES LIKE 
'binlog_row_value_options'",
+                                rs -> rs.next() ? rs.getString(2) : "")
+                        .trim()
+                        .toUpperCase();
+        // This setting was introduced in MySQL 8.0+ with default of empty 
string ''
+        // For older versions, assume empty string ''
+        if (!rowValueOptions.equals(BINLOG_ROW_VALUE_OPTIONS)) {
+            throw new ValidationException(
+                    String.format(
+                            "The MySQL server is configured with 
binlog_row_value_options=%s, which is possible to cause losing some binlog 
events"

Review Comment:
   ```suggestion
                               "The MySQL server is configured with 
binlog_row_value_options=%s, which is possible to cause losing some binlog 
events "
   ```



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