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: make concurrent ingest job queue instead of fallback #48645

Merged
merged 16 commits into from
Nov 21, 2023

Conversation

tangenta
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #47758

Problem Summary:

  1. only 1 ddl job can use ingest model and global sort.
  2. another add index job using txn merge.

What is changed and how it works?

  • This PR fixes problem 2 by making the concurrent adding index job queue.
  • Remove useless code.
  • Refactor improper usage of system variable.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    Add time.Sleep(20*time.Second) to the first phase of onCreateIndex().
    Session 1:
    mysql> alter table t add index i1 (a);
    Query OK, 0 rows affected (27.02 sec)
    
    Session 2:
    mysql> alter table t add index i2 (b);
    Query OK, 0 rows affected (46.31 sec)
    mysql> admin show ddl jobs 2;
    +--------+---------+------------+------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+--------+
    | JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE               | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | CREATE_TIME         | START_TIME          | END_TIME            | STATE  |
    +--------+---------+------------+------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+--------+
    |    110 | test    | t          | add index /* ingest */ | public       |         2 |      104 |         3 | 2023-11-16 16:47:15 | 2023-11-16 16:47:38 | 2023-11-16 16:48:01 | synced |
    |    109 | test    | t          | add index /* ingest */ | public       |         2 |      104 |         3 | 2023-11-16 16:47:14 | 2023-11-16 16:47:14 | 2023-11-16 16:47:38 | synced |
    +--------+---------+------------+------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+--------+
    2 rows in set (0.00 sec)
    
    Both jobs can use ingest now. You can also check the log:
    [2023/11/16 16:47:15.427 +08:00] [INFO] [backend_mgr.go:79] ["ingest backfill worker is already in used by another DDL job"] [category=ddl-ingest] ["processing job ID"=109]
    
  • 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/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 16, 2023
Copy link

tiprow bot commented Nov 16, 2023

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/test-infra repository.

Comment on lines 7341 to 7342
job.ReorgMeta.IsDistReorg = variable.EnableDistTask.Load()
job.ReorgMeta.IsFastReorg = variable.EnableFastReorg.Load()
Copy link
Contributor

Choose a reason for hiding this comment

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

If enbaleDistTask == true and enableFastReorg == false, what will happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mysql> set global tidb_enable_dist_task = 1;
Query OK, 0 rows affected (0.02 sec)

mysql> set global tidb_ddl_enable_fast_reorg = 0;
Query OK, 0 rows affected (0.03 sec)

mysql> alter table t add index i3(c);
Query OK, 0 rows affected (0.43 sec)

mysql> admin show ddl jobs 1;
+--------+---------+------------+---------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+--------+
| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE            | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | CREATE_TIME         | START_TIME          | END_TIME            | STATE  |
+--------+---------+------------+---------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+--------+
|    111 | test    | t          | add index /* txn */ | public       |         2 |      104 |         3 | 2023-11-16 17:16:52 | 2023-11-16 17:16:52 | 2023-11-16 17:16:53 | synced |
+--------+---------+------------+---------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+--------+
1 row in set (0.01 sec)

Copy link

codecov bot commented Nov 16, 2023

Codecov Report

Merging #48645 (b949d74) into master (3d176fc) will increase coverage by 1.5827%.
Report is 1 commits behind head on master.
The diff coverage is 53.8461%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #48645        +/-   ##
================================================
+ Coverage   71.1018%   72.6846%   +1.5827%     
================================================
  Files          1365       1389        +24     
  Lines        404348     411021      +6673     
================================================
+ Hits         287499     298749     +11250     
+ Misses        96883      93375      -3508     
+ Partials      19966      18897      -1069     
Flag Coverage Δ
integration 43.5754% <41.7582%> (?)
unit 71.1102% <53.8461%> (+0.0083%) ⬆️

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

Components Coverage Δ
dumpling 53.9874% <ø> (ø)
parser ∅ <ø> (∅)
br 48.7687% <ø> (-4.3201%) ⬇️

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 16, 2023
@ywqzzy
Copy link
Contributor

ywqzzy commented Nov 16, 2023

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 16, 2023
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Nov 16, 2023
@ywqzzy
Copy link
Contributor

ywqzzy commented Nov 17, 2023

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 17, 2023
errors.toml Outdated
@@ -1343,7 +1343,7 @@ Unsupported clustered primary key type FLOAT/DOUBLE for TTL

["ddl:8200"]
error = '''
Unsupported shard_row_id_bits for table with primary key as row id
Unsupported tidb_enable_dist_task setting. Please enable tidb_ddl_enable_fast_reorg to use distributed task execution.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why here use

Suggested change
Unsupported tidb_enable_dist_task setting. Please enable tidb_ddl_enable_fast_reorg to use distributed task execution.
Unsupported tidb_enable_dist_task setting. To utilize distributed task execution, please enable tidb_ddl_enable_fast_reorg first.

Copy link
Contributor

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Nov 17, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, ywqzzy

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 Nov 17, 2023
@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 17, 2023
Copy link

ti-chi-bot bot commented Nov 17, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-11-16 09:44:34.770032581 +0000 UTC m=+4328672.357142726: ☑️ agreed by ywqzzy.
  • 2023-11-17 09:18:01.68907343 +0000 UTC m=+4413479.276183559: ☑️ agreed by GMHDBJD.

@tangenta
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Nov 17, 2023

@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/test-infra repository.

@tangenta
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Nov 17, 2023

@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/test-infra repository.

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2023
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 18, 2023
@hawkingrei
Copy link
Member

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Nov 18, 2023
@tangenta
Copy link
Contributor Author

/retest

@hawkingrei
Copy link
Member

/test all

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 20, 2023
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 21, 2023
@hawkingrei
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot bot merged commit e41495d into pingcap:master Nov 21, 2023
16 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #48739.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[global sort] can not add index with global sort concurrency
6 participants