Skip to content

dxf: start scheduler without reserve resource in nextgen#63205

Merged
ti-chi-bot[bot] merged 7 commits into
pingcap:masterfrom
D3Hunter:skip-schedule-reserve-slot-nextgen
Aug 26, 2025
Merged

dxf: start scheduler without reserve resource in nextgen#63205
ti-chi-bot[bot] merged 7 commits into
pingcap:masterfrom
D3Hunter:skip-schedule-reserve-slot-nextgen

Conversation

@D3Hunter

@D3Hunter D3Hunter commented Aug 26, 2025

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #61702

Problem Summary:

What changed and how does it work?

in nextgen kernel, node resource will be scaled automatically by cluster controller which will use the schedule status API to make sure the required resource is available

also fix the integration tests in disttask pkg when run in nextgen

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

apply below diff

code diff
diff --git a/pkg/disttask/importinto/task_executor.go b/pkg/disttask/importinto/task_executor.go
index b774fe62df..f3923d5846 100644
--- a/pkg/disttask/importinto/task_executor.go
+++ b/pkg/disttask/importinto/task_executor.go
@@ -172,6 +172,7 @@ func (s *importStepExecutor) Add(bytes, rowCnt int64) {
 }
 
 func (s *importStepExecutor) RunSubtask(ctx context.Context, subtask *proto.Subtask) (err error) {
+	time.Sleep(time.Minute)
 	logger := s.logger.With(zap.Int64("subtask-id", subtask.ID))
 	task := log.BeginTask(logger, "run subtask")
 	defer func() {
diff --git a/pkg/executor/importer/import.go b/pkg/executor/importer/import.go
index 68b2dfa6c2..5ec5f13442 100644
--- a/pkg/executor/importer/import.go
+++ b/pkg/executor/importer/import.go
@@ -615,7 +615,7 @@ func (e *LoadDataController) checkFieldParams() error {
 func (p *Plan) initDefaultOptions(ctx context.Context, targetNodeCPUCnt int, store tidbkv.Storage) {
 	var threadCnt int
 	if kerneltype.IsNextGen() {
-		threadCnt = scheduler.CalcConcurrencyByDataSize(p.TotalFileSize, targetNodeCPUCnt)
+		threadCnt = 7
 	} else {
 		threadCnt = int(math.Max(1, float64(targetNodeCPUCnt)*0.5))
 		if p.DataSourceType == DataSourceTypeQuery {

run below script

create table t(id int); create table t1(id int);
import into t from 's3://mybucket/a.csv?access-key=minioadmin&secret-access-key=minioadmin&endpoint=http%3a%2f%2f0.0.0.0%3a9000' with detached;
select sleep(1);
select id,state,step,type,concurrency,max_node_count from mysql.tidb_global_task;
import into t1 from 's3://mybucket/a.csv?access-key=minioadmin&secret-access-key=minioadmin&endpoint=http%3a%2f%2f0.0.0.0%3a9000' with detached;
select sleep(1);
select id,state,step,type,concurrency,max_node_count from mysql.tidb_global_task;

before this PR, in the 2 queries of mysql.tidb_global_task;, we can see the second task is not scheduled

+----+---------+------+------------+-------------+----------------+
| id | state   | step | type       | concurrency | max_node_count |
+----+---------+------+------------+-------------+----------------+
|  1 | running |    1 | ImportInto |           7 |              1 |
+----+---------+------+------------+-------------+----------------+
...
+----+---------+------+------------+-------------+----------------+
| id | state   | step | type       | concurrency | max_node_count |
+----+---------+------+------------+-------------+----------------+
|  1 | running |    1 | ImportInto |           7 |              1 |
|  2 | pending |   -1 | ImportInto |           7 |              1 |
+----+---------+------+------------+-------------+----------------+

and the result of schedule status, we can see required_count is 1

➜  tikv-worker-test curl localhost:20080/dxf/schedule/status
{
 "version": 1,
 "task_queue": {
  "scheduled_count": 1
 },
 "tidb_worker": {
  "cpu_count": 10,
  "required_count": 1,
  "current_count": 1,
  "busy_nodes": [
   {
    "id": "192.168.206.85:5000",
    "is_owner": true
   }
  ]
 },
 "tikv_worker": {
  "required_count": 1
 }
}%

after this PR, in the 2 queries of mysql.tidb_global_task;, we can see both tasks are scheduled

+----+---------+------+------------+-------------+----------------+
| id | state   | step | type       | concurrency | max_node_count |
+----+---------+------+------------+-------------+----------------+
|  1 | running |    1 | ImportInto |           7 |              1 |
+----+---------+------+------------+-------------+----------------+
1 row in set (0.01 sec)

....

+----+---------+------+------------+-------------+----------------+
| id | state   | step | type       | concurrency | max_node_count |
+----+---------+------+------------+-------------+----------------+
|  1 | running |    1 | ImportInto |           7 |              1 |
|  2 | running |    1 | ImportInto |           7 |              1 |
+----+---------+------+------------+-------------+----------------+
2 rows in set (0.01 sec)

and the result of schedule status, we can see required_count is 2

➜  tikv-worker-test curl localhost:20080/dxf/schedule/status
{
 "version": 1,
 "task_queue": {
  "scheduled_count": 2
 },
 "tidb_worker": {
  "cpu_count": 10,
  "required_count": 2,
  "current_count": 1,
  "busy_nodes": [
   {
    "id": "192.168.206.85:5000",
    "is_owner": true
   }
  ]
 },
 "tikv_worker": {
  "required_count": 2
 }
}%
  • 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 26, 2025
@tiprow

tiprow Bot commented Aug 26, 2025

Copy link
Copy Markdown

Hi @D3Hunter. 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 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.7617%. Comparing base (eedab0e) to head (509b8bb).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #63205        +/-   ##
================================================
+ Coverage   72.7903%   74.7617%   +1.9714%     
================================================
  Files          1831       1877        +46     
  Lines        495232     504183      +8951     
================================================
+ Hits         360481     376936     +16455     
+ Misses       112839     103866      -8973     
- Partials      21912      23381      +1469     
Flag Coverage Δ
integration 48.4751% <0.0000%> (?)
unit 72.2609% <0.0000%> (+0.0006%) ⬆️

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

Components Coverage Δ
dumpling 52.8700% <ø> (ø)
parser ∅ <ø> (∅)
br 63.1662% <ø> (+16.8025%) ⬆️
🚀 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.

@joechenrh joechenrh left a comment

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.

Rest LGTM

}
require.Eventually(t, func() bool {
taskKeys := getRunningTaskKeys()
return err == nil && len(taskKeys) == 0

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.

Suggested change
return err == nil && len(taskKeys) == 0
return len(taskKeys) == 0

ditto for other place

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 26, 2025
@ti-chi-bot

ti-chi-bot Bot commented Aug 26, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joechenrh, wjhuang2016

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 approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 26, 2025
@ti-chi-bot

ti-chi-bot Bot commented Aug 26, 2025

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2025-08-26 09:07:08.57853233 +0000 UTC m=+258320.456363294: ☑️ agreed by joechenrh.
  • 2025-08-26 10:27:52.439327974 +0000 UTC m=+263164.317158918: ☑️ agreed by wjhuang2016.

@D3Hunter

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Aug 26, 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.

@hawkingrei

Copy link
Copy Markdown
Contributor

/retest

@ti-chi-bot ti-chi-bot Bot merged commit 36a2af4 into pingcap:master Aug 26, 2025
31 checks passed
@D3Hunter D3Hunter deleted the skip-schedule-reserve-slot-nextgen branch August 26, 2025 13:47
@D3Hunter

Copy link
Copy Markdown
Contributor Author

/cherry-pick release-nextgen-20250815

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Aug 26, 2025
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot

Copy link
Copy Markdown
Member

@D3Hunter: new pull request created to branch release-nextgen-20250815: #63214.
But this PR has conflicts, please resolve them!

Details

In response to this:

/cherry-pick release-nextgen-20250815

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 ti-community-infra/tichi repository.

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/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.

5 participants