[FLINK-36520] CDC Supports MySQL 8.x and above#3666
[FLINK-36520] CDC Supports MySQL 8.x and above#3666yuxiqian wants to merge 1 commit intoapache:masterfrom
Conversation
3087c70 to
17403e2
Compare
|
Could you investigate binlog compress feature would been supported via this PR or not? It requires MySQL 8.0.20 above version IIRC. |
|
Correct me if I'm wrong, but it looks like using the proper SQL command for showing binary logs is the only major change here. The rest is about refactoring the test suite. @leonardBang is the support for binlog compression a blocker for these changes to get merged?
@yuxiqian do you have any specific discussion topics in mind? As for testing, I believe having the test suite pass would be a great start, although it's not clear why the CI didn't run the tests on this PR. |
morozov
left a comment
There was a problem hiding this comment.
While this PR is being reviewed, I tried to test it and got a few questions.
| this.mysqlFieldReader = fieldReader; | ||
| this.urlPattern = connectionConfig.getUrlPattern(); | ||
|
|
||
| probeShowBinaryLogStatement(); |
There was a problem hiding this comment.
This method both returns the result of the probe and stores it in a property, which isn't nice from the CQRS standpoint (a method should either return a value or produce side effects, but not both).
Would it make sense to split it into private String probeShowBinaryLogStatement() and public String getShowBinaryLogStatement()? The constructor would call probe() and store the result in a property, and get() would return the property. In this case, the field can be made final, and the if (showBinaryLogStatement != null) condition could be removed.
Alternatively, if we want showBinaryLogStatement to be lazily initialized, the call to probeShowBinaryLogStatement() should be removed from the constructor. The first call will initialize it.
| MYSQL_NEW_SHOW_BINARY_LOG_STATEMENT, | ||
| MYSQL_CLASSIC_SHOW_BINARY_LOG_STATEMENT, | ||
| e); | ||
| query(MYSQL_CLASSIC_SHOW_BINARY_LOG_STATEMENT, rs -> {}); |
There was a problem hiding this comment.
If we're going to fall back to this statement anyways, why probe it? The corresponding code in Debezium looks simpler.
| "Probing with {} failed, try {}. Caused by: {}", | ||
| MYSQL_NEW_SHOW_BINARY_LOG_STATEMENT, | ||
| MYSQL_CLASSIC_SHOW_BINARY_LOG_STATEMENT, | ||
| e); |
There was a problem hiding this 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.
|
Thanks @morozov's kindly review!
I did some experiment earlier, and noticed that binlog compression would break current binlog backfilling code. However, considering this feature was introduced in MySQL 8.0.20, perhaps it could be handled independently.
Seems there are a lot of merging conflicts blocking the CI. Will resolve them soon. |
.github/workflows/flink_cdc.yml
Outdated
| matrix: | ||
| java-version: [ '8' ] | ||
| module: [ 'core', 'pipeline_connectors', 'mysql', 'postgres', 'oracle', 'mongodb6', 'mongodb7', 'sqlserver', 'tidb', 'oceanbase', 'db2', 'vitess' ] | ||
| module: [ 'core', 'pipeline_connectors', 'mysql57', 'mysql80', 'mysql84', 'mysql90', 'postgres', 'oracle', 'mongodb6', 'mongodb7', 'sqlserver', 'tidb', 'oceanbase', 'db2', 'vitess' ] |
There was a problem hiding this comment.
Do not use 'mysql90" as a label. Oracle has horrible versioning and basically you probably need to do one of the following: label as "mysql9x" as 9.X.0 changes every 3 months until it's expected to be 9.7 LTS in April 2026 and then numbers become normal again. e.g. expected to be 9.7.0, 9.7.1, ...
Basically 9.0 should not be used 9.3.0 is current innovation release and it'll be 9.4.0 on ~15th July. So until 9.X is confirmed to be LTS either don't mention it or label it 'mysql9x'.
Reference: https://dev.mysql.com/blog-archive/introducing-mysql-innovation-and-long-term-support-lts-versions/
Clearly do what makes sense but 'mysql90' will never be a useful label.
|
Hi, could you please let me know when this issue will go live? Thanks! |
|
A release of this would be very helpful as MySQL 8.0 is nearing it's end of life. |
|
Hi, I would like to ask why we do not use Debezium directly, but implement it ourselves? Debezium already supports MySQL 8 and above, and Debezium updates much faster than we do. |
Thanks for @shengjk's nice suggestion! For a long time we've been stuck at Debezium 1.9.x and monkey-patching Debezium, mainly for keeping compatibility with Java 8. FLINK-36605 also suggests a similar idea, but it is more likely to happen after bumping to Flink 2.x and dropping Java 8 support. |
|
@yuxiqian Hi, Is there any problem? Why is this PR in draft status? Does it have an expected merge date? |
Thanks @zhangshenghang for tracing this issue! IIRC, one concern from maintainers is we can't provide decent support for some newly introduced MySQL features, like Binlog compression, VECTOR data types, etc., without upgrading Debezium dependencies, which requires dropping Java 8 and Flink 1.x support. So this PR is, at best, a transitional solution. The next feature release (3.6 or 4.0) has not been kicked-off, but there's some discussions on upgrading Debezium versions here (https://issues.apache.org/jira/browse/FLINK-36605), so I'm not sure if it's appropriate to introduce this temporary change at this time. Anyway, I'll try to resolve all conflicts later this week so it could be marked ready for review. |
@yuxiqian Thank you for your reply. Yes, upgrading to JDK 11 would be a significant change. If there could be a temporary transitional solution for 1.8, that would also be a good option. |
Signed-off-by: yuxiqian <34335406+yuxiqian@users.noreply.github.com> # Conflicts: # .github/workflows/flink_cdc_base.yml # .github/workflows/flink_cdc_ci.yml # flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-mysql/src/test/java/org/apache/flink/cdc/connectors/mysql/source/MySqlFullTypesITCase.java # flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-mysql/src/test/java/org/apache/flink/cdc/connectors/mysql/source/MySqlMetadataAccessorITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/io/debezium/connector/mysql/util/ErrorMessageUtilsTest.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/LegacyMySqlTestBase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/debezium/reader/BinlogSplitReaderTest.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/table/MySqlCompatibilityITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/table/MySqlConnectorITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/table/MySqlTimezoneITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/testutils/MySqlVersion.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/polardbx/PolardbxSourceTestBase.java # Conflicts: # .github/workflows/flink_cdc_base.yml # .github/workflows/flink_cdc_ci.yml # .github/workflows/flink_cdc_ci_nightly.yml # flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-mysql/src/test/java/org/apache/flink/cdc/connectors/mysql/source/MySqlFullTypesITCase.java # flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/debezium/reader/BinlogSplitReaderTest.java
@yuxiqian Hi,I saw a discussion here about upgrading Debezium to version 2.7.x: https://issues.apache.org/jira/browse/FLINK-36605. |
|
Thanks @zhangshenghang for confirming this! Debezium 3.2 requiring Java 17 seems not very likely, since Flink 2.x still supports Java 11 (deprecated though). I'll fix CI test cases first. |
|
Hi, |

This closes FLINK-36520, FLINK-36590.
Currently, trying to use MySQL CDC with MySQL 8.4 would cause the following exception:
The reason is MySQL has changed some questionable words like
MASTERandSLAVEto more appropriate ones, so some commands are no longer compatible. Legacy MySqlSource (based on Debezium) wasn't fixed since it's not possible to upgrade Debezium dependency for now, and it has been deprecated for a long time anyway.Marked this PR as a draft, needs more discussion and testing over this.