Skip to content

importinto: update thread count after initialized data files#63200

Merged
ti-chi-bot[bot] merged 7 commits into
pingcap:masterfrom
tangenta:next-gen-fix-import-into-thread
Aug 28, 2025
Merged

importinto: update thread count after initialized data files#63200
ti-chi-bot[bot] merged 7 commits into
pingcap:masterfrom
tangenta:next-gen-fix-import-into-thread

Conversation

@tangenta

@tangenta tangenta commented Aug 26, 2025

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #61702

Problem Summary:

Before this PR, the node count & thread auto calculation does not work because the data size is initialized after Plan.initOptions.

What changed and how does it work?

  • This PR moves the auto calculation logic after LoadDataController.InitDataFiles.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
mysql> import into sbtest1 from "s3://test/*.csv?access-key=minioadmin&secret-access-key=minioadmin&endpoint=http://127.0.0.1:9000&force-path-style=true" with SKIP_ROWS=1;
+--------+-----------+-------------------------------------------------------------------------------------------------------------------------+------------------+----------+-------+----------+------------------+---------------+----------------+----------------------------+----------------------------+----------------------------+------------+----------------------------+----------+-------------------------+---------------------+-----------------------+----------------+--------------+
| Job_ID | Group_Key | Data_Source                                                                                                             | Target_Table     | Table_ID | Phase | Status   | Source_File_Size | Imported_Rows | Result_Message | Create_Time                | Start_Time                 | End_Time                   | Created_By | Last_Update_Time           | Cur_Step | Cur_Step_Processed_Size | Cur_Step_Total_Size | Cur_Step_Progress_Pct | Cur_Step_Speed | Cur_Step_ETA |
+--------+-----------+-------------------------------------------------------------------------------------------------------------------------+------------------+----------+-------+----------+------------------+---------------+----------------+----------------------------+----------------------------+----------------------------+------------+----------------------------+----------+-------------------------+---------------------+-----------------------+----------------+--------------+
|      2 | NULL      | s3://test/*.csv?access-key=xxxxxx&endpoint=http%3A%2F%2F127.0.0.1%3A9000&force-path-style=true&secret-access-key=xxxxxx | `test`.`sbtest1` |       10 |       | finished | 189.7MiB         |       1000000 |                | 2025-08-27 11:10:18.308084 | 2025-08-27 11:10:19.771820 | 2025-08-27 11:10:37.280906 | root@%     | 2025-08-27 11:10:37.280906 | NULL     | NULL                    | NULL                | NULL                  | NULL           | NULL         |
+--------+-----------+-------------------------------------------------------------------------------------------------------------------------+------------------+----------+-------+----------+------------------+---------------+----------------+----------------------------+----------------------------+----------------------------+------------+----------------------------+----------+-------------------------+---------------------+-----------------------+----------------+--------------+
1 row in set (19.26 sec)
[2025/08/27 11:10:19.787 +08:00] [INFO] [import.go:1319] ["set import thread count for nextgen kernel"] [keyspaceName=SYSTEM] [table=sbtest1] ["thread count"=1] ["max node count"=1] ["target node cpu count"=32] ["total file size"=189.7MiB]
  • 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

Signed-off-by: tangenta <tangenta@126.com>
@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 26, 2025
@tiprow

tiprow Bot commented Aug 26, 2025

Copy link
Copy Markdown

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.

Details

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.

@codecov

codecov Bot commented Aug 26, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 30.00000% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.7851%. Comparing base (a3d6d9e) to head (1952a76).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #63200        +/-   ##
================================================
+ Coverage   72.7884%   74.7851%   +1.9966%     
================================================
  Files          1831       1877        +46     
  Lines        495404     503615      +8211     
================================================
+ Hits         360597     376629     +16032     
+ Misses       112870     103656      -9214     
- Partials      21937      23330      +1393     
Flag Coverage Δ
integration 48.5438% <10.0000%> (?)
unit 72.3251% <30.0000%> (+0.0673%) ⬆️

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

Components Coverage Δ
dumpling 52.8700% <ø> (ø)
parser ∅ <ø> (∅)
br 63.2197% <ø> (+16.8789%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: tangenta <tangenta@126.com>
Comment thread pkg/executor/importer/import.go Outdated
Signed-off-by: tangenta <tangenta@126.com>
e.dataFiles = dataFiles
e.TotalFileSize = totalSize

if kerneltype.IsNextGen() {

@D3Hunter D3Hunter Aug 26, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add a integration test for it, we can enlarge the totalSize to be several times larger than original

Signed-off-by: tangenta <tangenta@126.com>
@ti-chi-bot ti-chi-bot Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 27, 2025
Comment thread tests/realtikvtest/importintotest/import_into_test.go
Comment thread pkg/executor/importer/import.go Outdated
Signed-off-by: tangenta <tangenta@126.com>
testfailpoint.Enable(s.T(), "github.com/pingcap/tidb/pkg/executor/importer/mockImportDataSize", fmt.Sprintf(`return(%d)`, tc.size))
testfailpoint.EnableCall(s.T(), "github.com/pingcap/tidb/pkg/executor/importer/mockImportDataSize", func(totalSize, targetNodeCPUCnt *int) {
*totalSize = tc.size
*targetNodeCPUCnt = 32

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

better not change this one, else the machine might not have enough slots to run the task. or you can mock the cpu count by mockNumCpu

@ti-chi-bot

ti-chi-bot Bot commented Aug 27, 2025

Copy link
Copy Markdown

@tangenta: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-integration-realcluster-test-next-gen 3a125f6 link true /test pull-integration-realcluster-test-next-gen

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

Signed-off-by: tangenta <tangenta@126.com>
@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 27, 2025
@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@tiprow

tiprow Bot commented Aug 27, 2025

Copy link
Copy Markdown

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

Details

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 commented Aug 28, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

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

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

The pull request process is described here

Details 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 Aug 28, 2025
@ti-chi-bot

ti-chi-bot Bot commented Aug 28, 2025

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2025-08-27 15:47:33.016718207 +0000 UTC m=+368744.894549171: ☑️ agreed by D3Hunter.
  • 2025-08-28 01:06:39.90423699 +0000 UTC m=+402291.782067934: ☑️ agreed by CbcWestwolf.

@hawkingrei

Copy link
Copy Markdown
Contributor

/retest

1 similar comment
@tangenta

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Aug 28, 2025

Copy link
Copy Markdown

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

Details

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.

@D3Hunter

Copy link
Copy Markdown
Contributor

/retest

@tiprow

tiprow Bot commented Aug 28, 2025

Copy link
Copy Markdown

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

Details

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 8d1a00e into pingcap:master Aug 28, 2025
29 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants