pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
37.08k stars 5.83k forks source link

TiDB schema diff is wrong #37804

Open lidezhu opened 2 years ago

lidezhu commented 2 years ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Load ch-benchmark(warehouse=1500) with tiflash replica using BR;

2. What did you expect to see? (Required)

All tables created in tiflash with no error;

3. What did you see instead (Required)

If print schema diff in tiflash log we can see the following two lines:

["SchemaDiff::deserialize:schema diff raw data {\"version\":35,\"type\":60,\"schema_id\":68,\"table_id\":0,\"old_table_id\":0,\"old_schema_id\":0,\"affected_options\":[{\"schema_id\":68,\"table_id\":70,\"old_table_id\":70,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":71,\"old_table_id\":71,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":72,\"old_table_id\":72,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":73,\"old_table_id\":73,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":74,\"old_table_id\":74,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":75,\"old_table_id\":75,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":76,\"old_table_id\":76,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":77,\"old_table_id\":77,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":78,\"old_table_id\":78,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":79,\"old_table_id\":79,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":80,\"old_table_id\":80,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":81,\"old_table_id\":81,\"old_schema_id\":68},{\"schema_id\":68,\"table_id\":82,\"old_table_id\":82,\"old_schema_id\":68}]}"]

["SchemaBuilder:Creating table chbenchmark(68).revenue1(76)"]

type: 60 means this is an action of createTables. But chbenchmark(68).revenue1(76) is a view which should be in a schema diff of type createView. So tiflash try to create a table for the view revenue1 but failed to do that and throw an exception.

4. What is your TiDB version? (Required)

master nightly

windtalker commented 2 years ago

Maybe it is a ddl related bug? @jebter

bb7133 commented 2 years ago

@lidezhu Could you provide detailed instructions on how to reproduce this? For example, how the data is prepared with ch-benchmark.

More information like the log of TiDB-server & SHOW CREATE TABLE chbenchmark(68).revenue1(76) would be also helpful.

Thanks.

lidezhu commented 2 years ago

Just use br to restore the data can produce the problem. I think this is just br's problem which put view in create tables diff.

lidezhu commented 2 years ago

The tag should be component/br, this problem should have nothing to do with tiflash. @jebter

3pointer commented 1 year ago

can we distinguish the view in tiflash side? ActionType: 60 is only used for br. actually it's means batchCreateTable with tableInfos. include tables/views. We can change the action name from CreateTables to CreateTableAndViews...

BornChanger commented 1 year ago

@lidezhu Can you check if this issue is fixed?

BornChanger commented 1 year ago

/remove-severity major

BornChanger commented 1 year ago

/severity minor

ti-chi-bot[bot] commented 1 year ago

@BornChanger: The label(s) severity/mionor cannot be applied, because the repository doesn't have them.

In response to [this](https://github.com/pingcap/tidb/issues/37804#issuecomment-1711495165): >/severity mionor Instructions for interacting with me using PR comments are available [here](https://prow.tidb.net/command-help). If you have questions or suggestions related to my behavior, please file an issue against the [ti-community-infra/tichi](https://github.com/ti-community-infra/tichi/issues/new?title=Prow%20issue:) repository.