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

select from information_schema.columns contains duplicate records #51829

Closed
D3Hunter opened this issue Mar 15, 2024 · 2 comments · Fixed by #51896
Closed

select from information_schema.columns contains duplicate records #51829

D3Hunter opened this issue Mar 15, 2024 · 2 comments · Fixed by #51896
Labels
affects-8.0 component/ddl This issue is related to DDL of TiDB. severity/critical type/bug This issue is a bug.

Comments

@D3Hunter
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

this bug is found during import 10K tables using lightning, and it get duplicate columns from tidb

mysql> SELECT table_name, column_name, column_type, generation_expression, extra FROM information_schema.columns WHERE table_schema = 'coms' ORDER BY table_name, ordinal_position limit 10;
+------------+-------------+---------------+-----------------------+-------+
| table_name | column_name | column_type   | generation_expression | extra |
+------------+-------------+---------------+-----------------------+-------+
| PK_10200   | COL1        | varbinary(10) |                       |       |
| PK_10200   | COL1        | varbinary(10) |                       |       |
| PK_10200   | COL2        | varchar(20)   |                       |       |
| PK_10200   | COL2        | varchar(20)   |                       |       |
| PK_10200   | COL4        | datetime      |                       |       |
| PK_10200   | COL4        | datetime      |                       |       |
| PK_10200   | COL3        | bigint(20)    |                       |       |
| PK_10200   | COL3        | bigint(20)    |                       |       |
| PK_10200   | COL5        | float         |                       |       |
| PK_10200   | COL5        | float         |                       |       |
+------------+-------------+---------------+-----------------------+-------+
10 rows in set (0.15 sec)

it works if i filter by table_name

mysql> SELECT table_name, column_name, column_type, generation_expression, extra FROM information_schema.columns WHERE table_schema = 'coms' and table_name='PK_10200' ORDER BY table_name, ordinal_position;
+------------+-------------+---------------+-----------------------+-------+
| table_name | column_name | column_type   | generation_expression | extra |
+------------+-------------+---------------+-----------------------+-------+
| PK_10200   | COL1        | varbinary(10) |                       |       |
| PK_10200   | COL2        | varchar(20)   |                       |       |
| PK_10200   | COL4        | datetime      |                       |       |
| PK_10200   | COL3        | bigint(20)    |                       |       |
| PK_10200   | COL5        | float         |                       |       |
+------------+-------------+---------------+-----------------------+-------+

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

no duplicate

3. What did you see instead (Required)

duplicate

4. What is your TiDB version? (Required)

mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                             |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.0.0-alpha
Edition: Community
Git Commit Hash: 630651209d7c5163d6f32a90587b17c15dc7be13
Git Branch: heads/refs/tags/v8.0.0-alpha
UTC Build Time: 2024-03-14 11:45:40
GoVersion: go1.21.6
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

@D3Hunter D3Hunter added type/bug This issue is a bug. severity/critical labels Mar 15, 2024
@D3Hunter D3Hunter added sig/sql-infra SIG: SQL Infra component/ddl This issue is related to DDL of TiDB. and removed sig/sql-infra SIG: SQL Infra labels Mar 15, 2024
@ywqzzy
Copy link
Contributor

ywqzzy commented Mar 18, 2024

Further more, I have found the query unstable with row count returned..

mysql --comments --host 10.2.12.147 --port 30098 -u root -e "SELECT * FROM information_schema.columns WHERE table_schema = 'coms';" > log.1

row count varies from 32552 to 32573

@ywqzzy
Copy link
Contributor

ywqzzy commented Mar 19, 2024

The order of tables returned by is.SchemaTables(schema) is unstable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-8.0 component/ddl This issue is related to DDL of TiDB. severity/critical type/bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants