flink-cdc icon indicating copy to clipboard operation
flink-cdc copied to clipboard

[FLINK-38247] Handle BIGINT UNSIGNED overflow in PreparedStatement

Open suhwan-cheon opened this issue 5 months ago • 4 comments

issue: https://issues.apache.org/jira/browse/FLINK-38247

Issue

An infinite loop occurred when using the MySqlChunkSplitter to split a table with a MySQL BIGINT UNSIGNED primary key. (This problem happens when the primary key value exceeds Long.MAX_VALUE)


Solution

I added StatementUtils.setSafeObject to detects the overflow and correctly converts the value to a BigDecimal before setting it in the PreparedStatement.


Verification

  • I added StatementUtilsTest to verify the correctness of StatementUtils.setSafeObject.
  • I used Java's dynamic proxy (createPreparedStatementProxy) to avoid creating a verbose mock class, simplifying the test code.

suhwan-cheon avatar Sep 14 '25 05:09 suhwan-cheon

Please add an itcase in MySqlSourceITCase.

lvyanquan avatar Sep 15 '25 01:09 lvyanquan

Run 'mvn spotless:apply' to fix these violations.

lvyanquan avatar Sep 19 '25 08:09 lvyanquan

Run 'mvn spotless:apply' to fix these violations.

I've applied it. Can you run the test again?

suhwan-cheon avatar Sep 19 '25 09:09 suhwan-cheon

there's a Checkstyle error. I'm not used to this environment, so I made a mistake. I've fixed Checkstyle error and ran the MySQL connector unit tests with mvn -pl flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc -DskipITs=true test please review.

suhwan-cheon avatar Sep 20 '25 07:09 suhwan-cheon