-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-34689][MySQL][Feature] check binlog_row_value_options #3148
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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 = ""; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
private final Properties dbzProperties; | ||||||
private final MySqlSourceConfig sourceConfig; | ||||||
|
@@ -70,6 +71,7 @@ public void validate() { | |||||
checkVersion(connection); | ||||||
checkBinlogFormat(connection); | ||||||
checkBinlogRowImage(connection); | ||||||
checkBinlogRowValueOptions(connection); | ||||||
checkTimeZone(connection); | ||||||
} catch (SQLException ex) { | ||||||
throw new TableException( | ||||||
|
@@ -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) : "") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
.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)) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
throw new ValidationException( | ||||||
String.format( | ||||||
"The MySQL server is configured with binlog_row_value_options %s rather than %s, which is " | ||||||
+ "required for this connector to work properly. Change the MySQL configuration to use a " | ||||||
+ "binlog_row_image='' and restart the connector.", | ||||||
rowValueOptions, BINLOG_ROW_VALUE_OPTIONS)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this error message should be changed as follows.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I do not understand wrong, we do not need to change the binlog_row_image setting. Am I right ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@ruanhang1993 Yes. we do not need to change both settings There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
} | ||||||
|
||||||
/** Check whether the server timezone matches the configured timezone. */ | ||||||
private void checkTimeZone(JdbcConnection connection) throws SQLException { | ||||||
String timeZoneProperty = dbzProperties.getProperty("database.serverTimezone"); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruanhang1993
How about changing the variable names
BINLOG_FORMAT_ROW
,BINLOG_FORMAT_IMAGE_FULL
toDEFAULT_BINLOG_FORMAT
,DEFAULT_BINLOG_ROW_FORMAT
?In mysql 8, default values for the
binlog_format
andbinlog_row_image
options areROW
andfull
, respectivelyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @SML0127 .
I think we could not change these fields' names. These settings are checked by the
ROW
orFULL
values.But the new
DEFAULT_BINLOG_ROW_VALUE_OPTIONS
is used as the default value for mysql 5.7. And it is to check whether this setting is set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your explanation, @ruanhang1993
I undertand your responses. Do you have any other suggestions?