-
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
[FLINK-34689][MySQL][Feature] check binlog_row_value_options #3148
Conversation
Thanks @SML0127 for the contribution, @ruanhang1993 Would you like to help review this PR? |
@ruanhang1993 PTAL |
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.
@SML0127 Hi. Sorry for the late review. I left a little comment. Thanks~
"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 comment
The reason will be displayed to describe this comment to others. Learn more.
I think this error message should be changed as follows.
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.
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.
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 comment
The 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 ?
@ruanhang1993
I updated log message.
Yes. we do not need to change both settings binlog_row_image
and binlog_row_value_options
.
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.
Hi, @SML0127.
I left some comments. Please take a look, thanks~
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
private static final String BINLOG_ROW_VALUE_OPTIONS = ""; | |
private static final String DEFAULT_BINLOG_ROW_VALUE_OPTIONS = ""; |
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 comment
The reason will be displayed to describe this comment to others. Learn more.
rs -> rs.next() ? rs.getString(2) : "") | |
rs -> rs.next() ? rs.getString(2) : DEFAULT_BINLOG_ROW_VALUE_OPTIONS) |
.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 comment
The reason will be displayed to describe this comment to others. Learn more.
if (!rowValueOptions.equals(BINLOG_ROW_VALUE_OPTIONS)) { | |
if (!BINLOG_ROW_VALUE_OPTIONS.equals(rowValueOptions)) { |
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" |
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.
"The MySQL server is configured with binlog_row_value_options=%s, which is possible to cause losing some binlog events" | |
"The MySQL server is configured with binlog_row_value_options=%s, which is possible to cause losing some binlog events " |
"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)); |
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.
rowValueOptions, BINLOG_ROW_VALUE_OPTIONS)); | |
rowValueOptions)); |
@ruanhang1993 |
private static final String BINLOG_FORMAT_ROW = "ROW"; | ||
private static final String BINLOG_FORMAT_IMAGE_FULL = "FULL"; |
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
to DEFAULT_BINLOG_FORMAT
, DEFAULT_BINLOG_ROW_FORMAT
?
private static final String BINLOG_FORMAT_ROW = "ROW"; | |
private static final String BINLOG_FORMAT_IMAGE_FULL = "FULL"; | |
private static final String DEFAULT_BINLOG_FORMAT = "ROW"; | |
private static final String DEFAULT_BINLOG_ROW_FORMAT = "FULL"; |
In mysql 8, default values for the binlog_format
and binlog_row_image
options are ROW
and full
, respectively
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.
Hi, @SML0127 .
I think we could not change these fields' names. These settings are checked by the ROW
or FULL
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?
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.
LGTM.
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.
@SML0127 Thanks for the contribution! LGTM
Implemented functino to check
binlog_row_value_optoins
within MySqlValidator.When
![pasted_image_at_2024-03-07T03_21_08 548Z](https://private-user-images.githubusercontent.com/13589283/313388100-5e81fb31-07ff-49bb-a0b1-f18f5955e5ee.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzODQ1MTMsIm5iZiI6MTczOTM4NDIxMywicGF0aCI6Ii8xMzU4OTI4My8zMTMzODgxMDAtNWU4MWZiMzEtMDdmZi00OWJiLWEwYjEtZjE4ZjU5NTVlNWVlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDE4MTY1M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFhYWY0ODlmNmExZDRiZDAwMTA0MWQyZDA2YzJjNWMwMDUwYTYxYzg0OGI5MTA0M2ViNmRjZGZlOTQyNzg1NTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.utH9oEorAuWyWnpfczQBOZ0jWXpxsQ-u8ZFoY8LvO8U)
binlog_row_value_optoins
is set toPARTIAL_JSON
,the update operator remains as
Update_rows_partial
.Flink CDC does not parse this event because
Update_row_partial
binlog event is mapped toPARTIAL_UPDATE_ROWS_EVENT
and Flink CDC do not handle that event type. Therefore, some update query-related binary logs are lost.So, we have to check
binlog_row_value_optoins
before starting.Implemented checkBinlogRowValueOptions