Skip to content
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

[Bug] Primary key issues with MySQL #3308

Open
1 of 2 tasks
CodyPin opened this issue May 8, 2024 · 6 comments
Open
1 of 2 tasks

[Bug] Primary key issues with MySQL #3308

CodyPin opened this issue May 8, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@CodyPin
Copy link

CodyPin commented May 8, 2024

Search before asking

  • I searched in the issues and found nothing similar.

Paimon version

0.7.0

Compute Engine

Flink 1.17.2

Minimal reproduce step

Not sure. The problem is inconsistent, on some MySQL server it won't happen, on some it will filter out most of the tables

What doesn't meet your expectations?

To load all the tables mentioned in the argument 'including_tables'

Anything else?

Removed by @CodyPin

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@CodyPin CodyPin added the bug Something isn't working label May 8, 2024
@CodyPin
Copy link
Author

CodyPin commented May 9, 2024

I have also tried paimon-flink-action-0.8, specifically paimon-flink-action-0.8-20240507.002037-81.jar from https://repository.apache.org/content/groups/snapshots/org/apache/paimon/paimon-flink-action/0.8-SNAPSHOT/paimon-flink-action-0.8-20240507.002037-81.jar but it just have the same effects. Maybe its something to do with table's metadata? Just guessing at this point

@MOBIN-F
Copy link
Contributor

MOBIN-F commented May 9, 2024

Does the ignored table have a schema change? You can set --ignore-incompatible false to check whether the table has schema changes, or check the log for "This table will be ignored".
paimon Cdc Ingestion supports a limited number of schema changes
@CodyPin

@CodyPin
Copy link
Author

CodyPin commented May 9, 2024

@MOBIN-F Thanks for the reply, this is my first try loading this database, so I guess it wouldn't matter if any of the tables has a schema change? I am not sure, in any case those table's schema haven't been touched since they were created. But I set the --ignore-incompatible for testing just to see if there would be any difference, but no, removing --ignore-incompatible or setting it to true doesn't have any difference.

And just to give more background, initially I was doing this with Flink and sinking into Iceberg, which would be able to get all the tables required, thus leading me to think it might be a Paimon issue either than Flink

@MOBIN-F
Copy link
Contributor

MOBIN-F commented May 10, 2024

I reproduced the problem, and the reason is as stated in the official documentation: If you do not have a PRIMARY KEY and an application asks for the PRIMARY KEY in your tables, MySQL returns the first UNIQUE index that has no NULL columns as the PRIMARY KEY.

CREATE TABLE test_implicit_pk (
id bigint(20) NOT null,
name varchar(255) NOT NULL,
school varchar(50) DEFAULT NULL,
UNIQUE key uk_sta_id (id,name),
UNIQUE KEY uk_sta (school)
) ENGINE=InnoDB

desc test_implicit_pk

Field |Type |Null|Key|Default|Extra|
------+------------+----+---+-------+-----+
id |bigint(20) |NO |PRI| | |
name |varchar(255)|NO |PRI| | |
school|varchar(50) |YES |UNI| | |

actual primary key information exists

show create table test_implicit_pk

CREATE TABLE `test_implicit_pk` (
   `id` bigint(20) NOT NULL,
   `name` varchar(255) NOT NULL,
   `school` varchar(50) DEFAULT NULL,
   UNIQUE KEY `uk_sta_id` (`id`,`name`),
   UNIQUE KEY `uk_sta` (`school`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

No primary key information is displayed

In this case, the primary key information cannot be obtained using metaData.getPrimaryKeys. Instead, we need to use metaData.getIndexInfo and metaData.getColumns to determine the primary key
what do you think? @JingsongLi @yuzelin

@CodyPin CodyPin changed the title [Bug] Wrongly filtering out some tables with mysql_sync_database when using Flink CDC from MySQL [Bug] Primary key issues with MySQL May 10, 2024
@yuzelin
Copy link
Contributor

yuzelin commented May 11, 2024

In this case, the primary key information cannot be obtained using metaData.getPrimaryKeys. Instead, we need to use metaData.getIndexInfo and metaData.getColumns to determine the primary key

Thanks for your suggestion @MOBIN-F , I will check it later.

@yuzelin yuzelin self-assigned this May 11, 2024
@MOBIN-F
Copy link
Contributor

MOBIN-F commented Sep 3, 2024

flink-cdc paimon pipeline connector does not have this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants