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

tidb_mdl_view is not showing blocked ddl when ddl contains multiple table #47743

Closed
D3Hunter opened this issue Oct 18, 2023 · 0 comments · Fixed by #48728
Closed

tidb_mdl_view is not showing blocked ddl when ddl contains multiple table #47743

D3Hunter opened this issue Oct 18, 2023 · 0 comments · Fixed by #48728
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. severity/major type/bug The issue is confirmed as a bug.

Comments

@D3Hunter
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  • create 2 table, t1, t2, insert 1 row to them.
  • in session 1:
begin;
select * from t1;
  • in session 2, the sql will block
rename table t1 to t11, t2 to t22;

now query block

mysql> select * from mysql.tidb_mdl_view;
Empty set (0.02 sec)

it's because we're not put all table id into ddl_jobs view as ActionMultiSchemaChange do:

if job.Type == model.ActionMultiSchemaChange {

query using this sql, we can see the block, 122 is the table id of t1:

mysql> SELECT job_id,
    ->     json_extract(cast(cast(job_meta as char) as json), '$.schema_name') as db_name,
    ->     json_extract(cast(cast(job_meta as char) as json), '$.table_name') as table_name,
    ->     json_extract(cast(cast(job_meta as char) as json), '$.query') as query,
    ->     session_id,
    ->     txnstart,
    ->     tidb_decode_sql_digests(all_sql_digests, 4096) AS SQL_DIGESTS
    ->   FROM mysql.tidb_ddl_job,
    ->     information_schema.cluster_tidb_trx,
    ->     information_schema.cluster_processlist
    ->   WHERE tidb_ddl_job.processing = 1 and Find_in_set(122, tidb_ddl_job.table_ids)
    ->     AND Find_in_set(122, cluster_tidb_trx.related_table_ids)
    ->     AND cluster_tidb_trx.session_id = cluster_processlist.id;
+--------+---------+------------+-------------------------------------+------------+----------------------------------------+--------------------------------+
| job_id | db_name | table_name | query                               | session_id | txnstart                               | SQL_DIGESTS                    |
+--------+---------+------------+-------------------------------------+------------+----------------------------------------+--------------------------------+
|    126 | "test"  | "t2"       | "rename table t1 to t11, t2 to t22" | 1103101964 | 10-18 14:46:58.547(445018700132384769) | ["begin","select * from `t1`"] |
+--------+---------+------------+-------------------------------------+------------+----------------------------------------+--------------------------------+

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

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

v7.4.0

@D3Hunter D3Hunter added the type/bug The issue is confirmed as a bug. label Oct 18, 2023
@aytrack aytrack added severity/major component/ddl This issue is related to DDL of TiDB. labels Oct 18, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 labels Oct 18, 2023
@ti-chi-bot ti-chi-bot added the affects-7.5 This bug affects the 7.5.x(LTS) versions. label Oct 23, 2023
@wjhuang2016 wjhuang2016 removed may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Jan 8, 2024
@ti-chi-bot ti-chi-bot bot closed this as completed in 35c0e8a Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. component/ddl This issue is related to DDL of TiDB. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants