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

*: LOAD DATA support WITH DETACHED #42159

Merged
merged 17 commits into from Mar 15, 2023
Merged

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Mar 13, 2023

What problem does this PR solve?

Issue Number: ref #40499

Problem Summary:

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code
MySQL [test]> load data infile 's3://load-csv/test.customer.aaaa.csv?access_key=xxx&secret_access_key=xxx' ignore into table my_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\\n' IGNORE 1 LINES with detached;
+--------+
| Job_ID |
+--------+
|  90001 |
+--------+
1 row in set (2.651 sec)

MySQL [test]> select * from mysql.load_data_jobs where job_id = 90001\G
*************************** 1. row ***************************
         job_id: 90001
expected_status: running
    create_time: 2023-03-13 17:15:17.887803
     start_time: 2023-03-13 17:15:17.890134
    update_time: 2023-03-13 17:15:25.945554
       end_time: 2023-03-13 17:15:25.958597
    data_source: s3://load-csv/test.customer.aaaa.csv?access_key=xxx&secret_access_key=xxx
   table_schema: test
     table_name: my_table
    import_mode: logical
    create_user: root@%
       progress: {"SourceFileSize":52428118,"LoadedFileSize":52428118,"LoadedRowCnt":89281}
 result_message: Records: 89281  Deleted: 0  Skipped: 0  Warnings: 65535
  error_message: NULL

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
Copy link
Member

ti-chi-bot commented Mar 13, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • D3Hunter
  • hawkingrei

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 13, 2023
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716 lance6716 changed the title [WIP] *: LOAD DATA support WITH DETACHED *: LOAD DATA support WITH DETACHED Mar 14, 2023
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 14, 2023
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 14, 2023
@lance6716
Copy link
Contributor Author

/cc @D3Hunter @xhebox

Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716
Copy link
Contributor Author

/test build

Comment on lines 938 to 941
if v.Detached {
if v.FileLocRef == ast.FileLocClient {
b.err = exeerrors.ErrLoadDataCantDetachWithLocal
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

we can move loadDataController out so we use controller.Detached.

we can check this inside controller to make all checks in one place

@@ -245,6 +270,7 @@ type LoadDataWorker struct {
progress atomic.Pointer[asyncloaddata.Progress]
getSysSessionFn func() (sessionctx.Context, error)
putSysSessionFn func(context.Context, sessionctx.Context)
ownSession bool
Copy link
Contributor

Choose a reason for hiding this comment

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

reuse detached? always has same value with it

) (err error) {
defer func() {
if e.ownSession {
e.putSysSessionFn(ctx, e.Ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe remove e.Ctx, we're using e.ctx and e.Ctx mixingly, it's same as ctx in InsertValues

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's made public for LOAD DATA LOCAL where the clientConn.handleLoadData check Ctx.GetSessionVars().Killed to handle reading packet. Maybe I can unify the CANCEL LOAD DATA JOB with this checking killed in next PR.

}
}()

s, err := e.getSysSessionFn()
Copy link
Contributor

Choose a reason for hiding this comment

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

why get a new session to execute job related sql?


defer func() {
ctx2 := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

make it work even ctx is cancelled? maybe leave a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 14, 2023
@@ -4238,6 +4248,12 @@ func (b *PlanBuilder) buildLoadData(ctx context.Context, ld *ast.LoadDataStmt) (
if err != nil {
return nil, err
}

if detached {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we move this into buildLoadData, so no need to init `detached

Copy link
Contributor Author

@lance6716 lance6716 Mar 14, 2023

Choose a reason for hiding this comment

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

This is already buildLoadData. You mean buildLoadData (executor)?

executor builder can not change the schema of plan, it's one way

Copy link
Contributor Author

@lance6716 lance6716 Mar 14, 2023

Choose a reason for hiding this comment

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

I moved it into buildLoadData (executor) and the query schema is not changed. Maybe other components have already read the old value and decided the query output before build executor.

@D3Hunter
Copy link
Contributor

/hold

@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 14, 2023
@lance6716
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 14, 2023
Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: f92a8b3

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 15, 2023
@lance6716
Copy link
Contributor Author

/test unit-test

@lance6716
Copy link
Contributor Author

/retest

@lance6716
Copy link
Contributor Author

/test unit-test

@ti-chi-bot
Copy link
Member

@lance6716: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test unit-test

Use /test all to run all jobs.

In response to this:

/test unit-test

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.

@lance6716
Copy link
Contributor Author

/test unit-test

@ti-chi-bot
Copy link
Member

@lance6716: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test unit-test

Use /test all to run all jobs.

In response to this:

/test unit-test

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.

@lance6716
Copy link
Contributor Author

/test unit-test

@ti-chi-bot
Copy link
Member

@lance6716: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test unit-test

Use /test all to run all jobs.

In response to this:

/test unit-test

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.

@lance6716
Copy link
Contributor Author

/test unit-test

@ti-chi-bot
Copy link
Member

@lance6716: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test unit-test

Use /test all to run all jobs.

In response to this:

/test unit-test

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.

@lance6716
Copy link
Contributor Author

/test unit-test

@lance6716
Copy link
Contributor Author

/retest

@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Mar 15, 2023
@lance6716
Copy link
Contributor Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 7752768

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 15, 2023
@hawkingrei hawkingrei added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 15, 2023
Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Mar 15, 2023
@lance6716
Copy link
Contributor Author

/unhold
/merge

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 15, 2023
@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 1831183

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 15, 2023
@lance6716
Copy link
Contributor Author

/retest

@ti-chi-bot ti-chi-bot merged commit 982e0dc into pingcap:master Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants