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

ddl: assign table IDs for jobs submitted to queue #54880

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Jul 24, 2024

What problem does this PR solve?

Issue Number: close #54703

Problem Summary:

Timeline:

  1. Create a TiDB v6.1.7 cluster.
  2. Add a TiDB nightly instance. It will trigger the upgrade procedure.
  3. Submit upgrade DDLs at TiDB nightly, and TiDB v6.1.7 will run it as DDL owner.

Because concurrent DDL is not implemented in TiDB v6.1, these upgrade DDLs will be submited to the queue. However, #54669 does not consider those jobs who are submited to queue, new TiDB does not assign table IDs for create tables/views/sequences jobs.

[2024/07/24 15:45:21.524 +08:00] [INFO] [ddl_worker.go:264] ["add DDL jobs"] [category=ddl] ["batch count"=1] [jobs="ID:72, Type:create table, State:queueing, SchemaState:none, SchemaID:3, TableID:0, RowCount:0, ArgLen:2, start time: 2024-07-24 15:45:21.484 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0, LocalMode: false; "] [table=false]

From the log we can see table ID is zero. Then TiDB will report the error "table is already exists".

What changed and how does it work?

  • Assign table IDs for jobs before enqueuing.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    After this PR, we can run upgrade procedure normally.
    -- TiDB master
    [2024/07/24 20:58:14.061 +08:00] [INFO] [ddl.go:1222] ["start DDL job"] [category=ddl] [job="ID:127, Type:create view, State:queueing, SchemaState:none, SchemaID:3, TableID:127, RowCount:0, ArgLen:3, start time: 2024-07-24 20:58:14.01 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0, LocalMode: false"] [query="CREATE OR REPLACE SQL SECURITY INVOKER VIEW mysql.tidb_mdl_view as (\n\t\tSELECT tidb_mdl_info.job_id,\n\t\t\tJSON_UNQUOTE(JSON_EXTRACT(cast(cast(job_meta as char) as json), \"$.schema_name\")) as db_name,\n\t\t\tJSON_UNQUOTE(JSON_EXTRACT(cast(cast(job_meta as char) as json), \"$.table_name\")) as table_name,\n\t\t\tJSON_UNQUOTE(JSON_EXTRACT(cast(cast(job_meta as char) as json), \"$.query\")) as query,\n\t\t\tsession_id,\n\t\t\tcluster_tidb_trx.start_time,\n\t\t\ttidb_decode_sql_digests(all_sql_digests, 4096) AS SQL_DIGESTS\n\t\tFROM mysql.tidb_ddl_job,\n\t\t\tmysql.tidb_mdl_info,\n\t\t\tinformation_schema.cluster_tidb_trx\n\t\tWHERE tidb_ddl_job.job_id=tidb_mdl_info.job_id\n\t\t\tAND CONCAT(',', tidb_mdl_info.table_ids, ',') REGEXP CONCAT(',(', REPLACE(cluster_tidb_trx.related_table_ids, ',', '|'), '),') != 0\n\t);"]
    [2024/07/24 20:58:14.079 +08:00] [INFO] [domain.go:339] ["diff load InfoSchema success"] [isV2=false] [currentSchemaVersion=111] [neededSchemaVersion=112] ["elapsed time"=431.339µs] [gotSchemaVersion=112] [phyTblIDs="[124,127]"] [actionTypes="[21,21]"] [diffTypes="[\"create view\"]"]
    [2024/07/24 20:58:14.564 +08:00] [INFO] [ddl.go:1332] ["DDL job is finished"] [category=ddl] [jobID=127]
    
    -- TiDB v6.1.7 (DDL owner)
    [2024/07/24 20:58:13.755 +08:00] [INFO] [ddl_worker.go:475] ["[ddl] finish DDL job"] [worker="worker 1, tp general"] [job="ID:126, Type:drop table, State:synced, SchemaState:none, SchemaID:3, TableID:47, RowCount:0, ArgLen:3, start time: 2024-07-24 20:58:13.459 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0"]
    [2024/07/24 20:58:14.063 +08:00] [INFO] [ddl_worker.go:819] ["[ddl] run DDL job"] [worker="worker 1, tp general"] [job="ID:127, Type:create view, State:queueing, SchemaState:none, SchemaID:3, TableID:127, RowCount:0, ArgLen:0, start time: 2024-07-24 20:58:14.01 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0"]
    [2024/07/24 20:58:14.079 +08:00] [INFO] [domain.go:150] ["diff load InfoSchema success"] [currentSchemaVersion=111] [neededSchemaVersion=112] ["start time"=821.105µs] [phyTblIDs="[124,127]"] [actionTypes="[2097152,2097152]"]
    [2024/07/24 20:58:14.128 +08:00] [INFO] [ddl_worker.go:1027] ["[ddl] wait latest schema version changed"] [worker="worker 1, tp general"] [ver=112] ["take time"=54.901176ms] [job="ID:127, Type:create view, State:done, SchemaState:public, SchemaID:3, TableID:127, RowCount:0, ArgLen:3, start time: 2024-07-24 20:58:14.01 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0"]
    [2024/07/24 20:58:14.130 +08:00] [INFO] [ddl_worker.go:475] ["[ddl] finish DDL job"] [worker="worker 1, tp general"] [job="ID:127, Type:create view, State:synced, SchemaState:public, SchemaID:3, TableID:127, RowCount:0, ArgLen:0, start time: 2024-07-24 20:58:14.01 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0"]
    
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 24, 2024
Copy link

tiprow bot commented Jul 24, 2024

Hi @tangenta. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

codecov bot commented Jul 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 56.8946%. Comparing base (d6723ab) to head (9143cb7).
Report is 12 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54880         +/-   ##
=================================================
- Coverage   72.8477%   56.8946%   -15.9531%     
=================================================
  Files          1558       1681        +123     
  Lines        438428     623387     +184959     
=================================================
+ Hits         319385     354674      +35289     
- Misses        99360     244964     +145604     
- Partials      19683      23749       +4066     
Flag Coverage Δ
integration 38.3890% <0.0000%> (?)
unit 72.4139% <0.0000%> (+0.5534%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 52.9166% <ø> (+7.0545%) ⬆️

Copy link
Contributor

@lance6716 lance6716 left a comment

Choose a reason for hiding this comment

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

Seems we

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 25, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 25, 2024
Copy link

ti-chi-bot bot commented Jul 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-25 03:22:57.29698839 +0000 UTC m=+1101799.287929860: ☑️ agreed by lance6716.
  • 2024-07-25 03:23:57.316039082 +0000 UTC m=+1101859.306980552: ☑️ agreed by D3Hunter.

@D3Hunter D3Hunter changed the title ddl: assign table IDs for jobs before enqueuing ddl: assign table IDs for jobs submitted to queue Jul 25, 2024
@tangenta
Copy link
Contributor Author

/approve

@tangenta
Copy link
Contributor Author

/retest

Copy link

ti-chi-bot bot commented Jul 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, lance6716, tangenta

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Jul 25, 2024
Copy link

tiprow bot commented Jul 25, 2024

@tangenta: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@lance6716
Copy link
Contributor

/retest

Copy link

tiprow bot commented Jul 25, 2024

@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@lance6716
Copy link
Contributor

/retest

Copy link

tiprow bot commented Jul 25, 2024

@lance6716: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@tangenta
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Jul 25, 2024

@tangenta: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot merged commit cf4bb51 into pingcap:master Jul 25, 2024
23 checks passed
morgo added a commit to morgo/tidb that referenced this pull request Jul 28, 2024
* upstream/master: (93 commits)
  disjoinset: add generic impl (pingcap#54917)
  planner: derive index filters for mv index paths (pingcap#54877)
  br: cli refactor backup error handling logic (pingcap#54697)
  expression: fix infinity loop in `timestampadd` (pingcap#54916)
  planner: import more expand test. (pingcap#54962)
  planner: use code-gen to generate CloneForPlanCache method for some operators (pingcap#54957)
  test: fix flaky test TestFailSchemaSyncer (pingcap#54958)
  planner: move logical show into logicalop pkg. (pingcap#54928)
  privilege: Remove TestAbnormalMySQLTable (pingcap#54925)
  resource_control: support unlimited keyword when setting the resource group (pingcap#54704)
  ddl: fix a data race on localRowCntListener Written() (pingcap#54484)
  lightning: fix SET SESSION on connection pool (pingcap#54927)
  planner: move logical mem-table to logicalop pkg. (pingcap#54903)
  table: Add `CachedTableSupport` and `TemporaryTableSupport` for `MutateContext` (pingcap#54900)
  executor: fix index_hash_join hang when context canceled (pingcap#54855)
  statistics: add metrics for unneeded analyze table (pingcap#54822)
  *: refine pipelined dml benchmarks (pingcap#54844)
  ddl: assign table IDs for jobs submitted to queue (pingcap#54880)
  *: avoid using Tables field of model.DBInfo, use API instead (pingcap#52302)
  planner: remove useless check (pingcap#54907)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Operator upgrade TiDB Cluster Failed
3 participants