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

model: add schema name, table name to ddl job. #11561

Merged
merged 12 commits into from
Aug 5, 2019

Conversation

crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented Aug 1, 2019

What problem does this PR solve?

  • add schema name, table name, end_ts to ddl job.

Related parser PR: pingcap/parser#422

Before:
The schema name and table name maybe "" after the database or table droped.

mysql>admin show ddl jobs
+--------+---------+------------+---------------+--------------+-----------+----------+-----------+-----------------------------------+--------+
| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE      | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | START_TIME                        | STATE  |
+--------+---------+------------+---------------+--------------+-----------+----------+-----------+-----------------------------------+--------+
| 105    |         |            | drop schema   | none         | 100       | 0        | 0         | 2019-08-01 14:01:31.355 +0800 CST | synced |
| 104    |         |            | drop table    | none         | 100       | 102      | 0         | 2019-08-01 14:00:40.406 +0800 CST | synced |
| 103    |         |            | create table  | public       | 100       | 102      | 0         | 2019-08-01 14:00:37.955 +0800 CST | synced |
| 101    |         |            | create schema | public       | 100       | 0        | 0         | 2019-08-01 14:00:32.953 +0800 CST | synced |
| 99     |         |            | drop schema   | none         | 95        | 0        | 0         | 2019-08-01 14:00:23.752 +0800 CST | synced |
| 98     |         |            | create table  | public       | 95        | 97       | 0         | 2019-08-01 14:00:12.502 +0800 CST | synced |
| 96     |         |            | create schema | public       | 95        | 0        | 0         | 2019-08-01 14:00:00.304 +0800 CST | synced |
| 94     |         |            | drop schema   | none         | 90        | 0        | 0         | 2019-08-01 13:59:57.807 +0800 CST | synced |
| 93     |         |            | create table  | public       | 90        | 92       | 0         | 2019-08-01 13:54:00.504 +0800 CST | synced |
| 91     |         |            | create schema | public       | 90        | 0        | 0         | 2019-08-01 13:53:53.553 +0800 CST | synced |
+--------+---------+------------+---------------+--------------+-----------+----------+-----------+-----------------------------------+--------+

This PR
(DDL 93 and 91 don't have name because it is the old version ddl job.)

mysql>admin show ddl jobs                                                                                                                                                                                                                                                                                       │| synced |
+--------+---------+------------+---------------+--------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+--------+                                                                                                                            │| 104    |         |            | drop table    | none         | 10
| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE      | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | START_TIME                        | END_TIME                          | STATE  |                                                                                                                            │0       | 102      | 0         | 2019-08-01 14:00:40.406 +0800 CST
+--------+---------+------------+---------------+--------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+--------+                                                                                                                            │| synced |
| 105    | test    |            | drop schema   | none         | 100       | 0        | 0         | 2019-08-01 14:01:31.355 +0800 CST | 2019-08-01 14:01:31.556 +0800 CST | synced |                                                                                                                            │| 103    |         |            | create table  | public       | 10
| 104    | test    | t1         | drop table    | none         | 100       | 102      | 0         | 2019-08-01 14:00:40.406 +0800 CST | 2019-08-01 14:00:40.606 +0800 CST | synced |                                                                                                                            │0       | 102      | 0         | 2019-08-01 14:00:37.955 +0800 CST
| 103    | test    | t1         | create table  | public       | 100       | 102      | 0         | 2019-08-01 14:00:37.955 +0800 CST | 2019-08-01 14:00:38.005 +0800 CST | synced |                                                                                                                            │| synced |
| 101    | test    |            | create schema | public       | 100       | 0        | 0         | 2019-08-01 14:00:32.953 +0800 CST | 2019-08-01 14:00:33.004 +0800 CST | synced |                                                                                                                            │| 101    |         |            | create schema | public       | 10
| 99     | test    |            | drop schema   | none         | 95        | 0        | 0         | 2019-08-01 14:00:23.752 +0800 CST | 2019-08-01 14:00:23.952 +0800 CST | synced |                                                                                                                            │0       | 0        | 0         | 2019-08-01 14:00:32.953 +0800 CST
| 98     | test    | t1         | create table  | public       | 95        | 97       | 0         | 2019-08-01 14:00:12.502 +0800 CST | 2019-08-01 14:00:12.557 +0800 CST | synced |                                                                                                                            │| synced |
| 96     | test    |            | create schema | public       | 95        | 0        | 0         | 2019-08-01 14:00:00.304 +0800 CST | 2019-08-01 14:00:00.356 +0800 CST | synced |                                                                                                                            │| 99     |         |            | drop schema   | none         | 95
| 94     | test    |            | drop schema   | none         | 90        | 0        | 0         | 2019-08-01 13:59:57.807 +0800 CST | 2019-08-01 13:59:57.952 +0800 CST | synced |                                                                                                                            │        | 0        | 0         | 2019-08-01 14:00:23.752 +0800 CST
| 93     |         |            | create table  | public       | 90        | 92       | 0         | 2019-08-01 13:54:00.504 +0800 CST | 2019-08-01 13:54:00.554 +0800 CST | synced |                                                                                                                            │| synced |
| 91     |         |            | create schema | public       | 90        | 0        | 0         | 2019-08-01 13:53:53.553 +0800 CST | 2019-08-01 13:53:53.601 +0800 CST | synced |                                                                                                                            │| 98     |         |            | create table  | public       | 95
+--------+---------+------------+---------------+--------------+-----------+----------+-----------+-----------------------------------+-----------------------------------+--------+

TiDB used to only store the schema ID and table ID in DDL job info, When executing admin show ddl jobs, TiDB use infoschema to find schema/table name by the schema ID and table ID. But after we drop the database or table, this does not work any more.

What is changed and how it works?

  • add schema name, table name to the DDL job info.

Check List

Tests

  • Unit test
    Code changes

  • Has exported function/method change

Side effects

Related changes

@crazycs520 crazycs520 changed the title model: add schema name, table name, end_ts to ddl job. model: add schema name, table name to ddl job. Aug 1, 2019
@codecov
Copy link

codecov bot commented Aug 1, 2019

Codecov Report

Merging #11561 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #11561   +/-   ##
===========================================
  Coverage   81.5429%   81.5429%           
===========================================
  Files           426        426           
  Lines         93368      93368           
===========================================
  Hits          76135      76135           
  Misses        11855      11855           
  Partials       5378       5378

go.sum Outdated Show resolved Hide resolved
Copy link
Contributor

@tangenta tangenta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AilinKid
Copy link
Contributor

AilinKid commented Aug 2, 2019

/Rest LGTM

@AilinKid
Copy link
Contributor

AilinKid commented Aug 5, 2019

/LGTM

@crazycs520
Copy link
Contributor Author

/run-all-tests

executor/executor_test.go Outdated Show resolved Hide resolved
ddl/ddl_api.go Show resolved Hide resolved
Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@crazycs520
Copy link
Contributor Author

/run-all-tests

@crazycs520
Copy link
Contributor Author

/run-integration-common-test

@crazycs520 crazycs520 merged commit 265b654 into pingcap:master Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants