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, lightning: integrate operator for global sort #46734

Merged
merged 35 commits into from
Sep 12, 2023

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Sep 6, 2023

What problem does this PR solve?

Issue Number: ref #45719

Problem Summary:

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    1. Create a tiup cluster:
    tiup playground nightly --db 0 --kv 1 --pd 1  --without-monitor
    
    1. Add three tidb servers:
    ./bin/tidb-server -P 4000 --store=tikv --host=127.0.0.1 --status=10080 --path=127.0.0.1:2379 --log-file=tidb-0.log
    ./bin/tidb-server -P 4001 --store=tikv --host=127.0.0.1 --status=10081 --path=127.0.0.1:2379 --log-file=tidb-1.log
    ./bin/tidb-server -P 4002 --store=tikv --host=127.0.0.1 --status=10082 --path=127.0.0.1:2379 --log-file=tidb-2.log
    
    1. Insert 10 million rows:
    sysbench --test=oltp_read_write --table-size=10000000 --db-driver=mysql --mysql-user=root --mysql-password='' --mysql-host=127.0.0.1 --mysql-port=4000 --mysql-db=test --threads=4 --time=1800 --report-interval=1 prepare
    WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
    sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
    
    Initializing worker threads...
    
    Creating table 'sbtest1'...
    Inserting 10000000 records into 'sbtest1'
    Creating a secondary index on 'sbtest1'...
    
    1. Start minio server and create a bucket 'globalsort':
    ./minio server ./data
    
    1. Create a bucket through minio web interface.
    2. Enable dist task and set system variable tidb_cloud_storage_uri:
    mysql> set @@global.tidb_enable_dist_task = 1;
    Query OK, 0 rows affected (0.01 sec)
    mysql> set @@global.tidb_cloud_storage_uri = "s3://globalsort/addindex?access-key=minioadmin&secret-access-key=minioadmin&endpoint=http://127.0.0.1:9000&force-path-style=true";
    Query OK, 0 rows affected (0.01 sec)
    
    1. Add index for sbtest1:
    mysql> alter table sbtest1 add index idx(k);
    Query OK, 0 rows affected (5.87 sec)
    
    1. Show jobs and admin check:
    mysql> admin show ddl jobs;
    +--------+---------+-------------------------+------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+--------+
    | JOB_ID | DB_NAME | TABLE_NAME              | JOB_TYPE               | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | CREATE_TIME         | START_TIME          | END_TIME            | STATE  |
    +--------+---------+-------------------------+------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+--------+
    |    103 | test    | sbtest1                 | add index /* ingest */ | public       |         2 |      100 |  10000000 | 2023-09-12 16:27:35 | 2023-09-12 16:27:35 | 2023-09-12 16:27:41 | synced |
    ...
    +--------+---------+-------------------------+------------------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+--------+
    10 rows in set (0.02 sec)
    
    mysql> admin check table sbtest1;
    Query OK, 0 rows affected (4.20 sec)
    
  • No code

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

Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 6, 2023
@tiprow
Copy link

tiprow bot commented Sep 6, 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.

@tangenta
Copy link
Contributor Author

tangenta commented Sep 7, 2023

Wait for #46636 and #46407

Copy link
Contributor

@D3Hunter D3Hunter left a comment

Choose a reason for hiding this comment

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

29/32

if err != nil {
return nil, err
}
err = local.ImportEngine(ctx, engineUUID, int64(config.SplitRegionSize), int64(config.SplitRegionKeys))
Copy link
Contributor

Choose a reason for hiding this comment

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

from what this stage does, should it be named as write&ingest stage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ywqzzy changed the behavior of framework in #46593. Maybe we need to discuss how to operate the stages.

Copy link
Contributor

@D3Hunter D3Hunter left a comment

Choose a reason for hiding this comment

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

so in this pr, there is no merge sort range overlapped files part?

@tangenta
Copy link
Contributor Author

@D3Hunter Mulitple-pass merge sort will be implemented in next PR.

// This flow for partition table has only one step
switch gTask.Step {
case stageInit:
gTask.Step = stageReadIndex
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

framework also changes step, we need unify where we can change steps, see https://github.com/pingcap/tidb/pull/46593/files#diff-2a828989b540648a0bdef3d984d7946ea4fcb3c18718a4047b320c712ee1b855R424

I'm trying to change it.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Sep 12, 2023
Comment on lines +81 to +82
if err := taskHandle.UpdateTask(gTask.State, nil, dispatcher.RetrySQLTimes); err != nil {
logutil.Logger(ctx).Error("failed to UpdateTask", zap.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

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

seems this changes nothing? @ywqzzy

Copy link
Contributor

Choose a reason for hiding this comment

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

I will move this to framework in the next pr

Copy link
Contributor

Choose a reason for hiding this comment

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

as discussed, we will move all task status change to framework later. cc @ywqzzy

// LockForWrite implements ingest.Writer.
// Since flushKVs is thread-safe in external storage writer,
// this is implemented as noop.
func (w *Writer) LockForWrite() func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can provide a batch version WriteRows. We can discuss it later.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 12, 2023

[APPROVALNOTIFIER] This PR is APPROVED

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

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 12, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 12, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-09-12 07:28:44.791628116 +0000 UTC m=+340706.716184507: ☑️ agreed by D3Hunter.
  • 2023-09-12 07:36:57.894256373 +0000 UTC m=+341199.818812768: ☑️ agreed by lance6716.

@D3Hunter
Copy link
Contributor

/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 Sep 12, 2023
@D3Hunter
Copy link
Contributor

/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 Sep 12, 2023
@ywqzzy
Copy link
Contributor

ywqzzy commented Sep 12, 2023

/retest

@tiprow
Copy link

tiprow bot commented Sep 12, 2023

@ywqzzy: 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 merged commit be2a243 into pingcap:master Sep 12, 2023
16 of 20 checks passed
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants