Skip to content

dxf: fix incorrect worker count metric when total task count exceed schedule limit#64321

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
D3Hunter:fix-dxf-worker-metric
Nov 6, 2025
Merged

dxf: fix incorrect worker count metric when total task count exceed schedule limit#64321
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
D3Hunter:fix-dxf-worker-metric

Conversation

@D3Hunter

@D3Hunter D3Hunter commented Nov 6, 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?

we pass the wrong tasks param when calculate for the worker count metric

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
apply this diff, we we can only run at most 2 task at the same time, force the task concurrency = node CPU, and let the task wait

diff --git a/pkg/disttask/framework/proto/task.go b/pkg/disttask/framework/proto/task.go
index 0ca1162f22..cd3e5bd18a 100644
--- a/pkg/disttask/framework/proto/task.go
+++ b/pkg/disttask/framework/proto/task.go
@@ -65,7 +65,7 @@ const (
 
 // MaxConcurrentTask is the max concurrency of task.
 // TODO: remove this limit later.
-var MaxConcurrentTask = 16
+var MaxConcurrentTask = 2
 
 // ExtraParams is the extra params of task.
 // Note: only store params that's not used for filter or sort in this struct.
diff --git a/pkg/disttask/importinto/task_executor.go b/pkg/disttask/importinto/task_executor.go
index 4a57bbfd00..4f633f80ae 100644
--- a/pkg/disttask/importinto/task_executor.go
+++ b/pkg/disttask/importinto/task_executor.go
@@ -183,6 +183,7 @@ func (s *importStepExecutor) Processed(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 e3f78ff6a9..56e1151251 100644
--- a/pkg/executor/importer/import.go
+++ b/pkg/executor/importer/import.go
@@ -1422,7 +1422,7 @@ func (e *LoadDataController) CalResourceParams(ctx context.Context, ksCodec []by
 		}
 	}
 	cal := scheduler.NewRCCalc(totalSize, targetNodeCPUCnt, indexSizeRatio, factors)
-	e.ThreadCnt = cal.CalcConcurrency()
+	e.ThreadCnt = targetNodeCPUCnt
 	e.MaxNodeCnt = cal.CalcMaxNodeCountForImportInto()
 	e.DistSQLScanConcurrency = scheduler.CalcDistSQLConcurrency(e.ThreadCnt, e.MaxNodeCnt, targetNodeCPUCnt)
 	e.logger.Info("auto calculate resource related params",

previously

# HELP tidb_dxf_worker_count Gauge of DXF worker count.
# TYPE tidb_dxf_worker_count gauge
tidb_dxf_worker_count{keyspace_name="SYSTEM",type="current"} 1
tidb_dxf_worker_count{keyspace_name="SYSTEM",type="required"} 3

after

# HELP tidb_dxf_worker_count Gauge of DXF worker count.
# TYPE tidb_dxf_worker_count gauge
tidb_dxf_worker_count{keyspace_name="SYSTEM",type="current"} 1
tidb_dxf_worker_count{keyspace_name="SYSTEM",type="required"} 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/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 6, 2025
@tiprow

tiprow Bot commented Nov 6, 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.

@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 6, 2025
@ti-chi-bot

ti-chi-bot Bot commented Nov 6, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 6, 2025
@ti-chi-bot

ti-chi-bot Bot commented Nov 6, 2025

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2025-11-06 11:40:15.969497056 +0000 UTC m=+356665.412526925: ☑️ agreed by GMHDBJD.
  • 2025-11-06 12:07:39.248550699 +0000 UTC m=+358308.691580578: ☑️ agreed by wjhuang2016.

@codecov

codecov Bot commented Nov 6, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.4995%. Comparing base (779e298) to head (d7ec9fe).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #64321        +/-   ##
================================================
+ Coverage   72.7432%   73.4995%   +0.7563%     
================================================
  Files          1861       1862         +1     
  Lines        504392     505588      +1196     
================================================
+ Hits         366911     371605      +4694     
+ Misses       115176     111886      -3290     
+ Partials      22305      22097       -208     
Flag Coverage Δ
integration 41.7375% <0.0000%> (?)
unit 72.6453% <100.0000%> (+0.3319%) ⬆️

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

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

@D3Hunter

D3Hunter commented Nov 6, 2025

Copy link
Copy Markdown
Contributor Author

/cherry-pick release-nextgen-20251011

@ti-chi-bot

Copy link
Copy Markdown
Member

@D3Hunter: once the present PR merges, I will cherry-pick it on top of release-nextgen-20251011 in the new PR and assign it to you.

Details

In response to this:

/cherry-pick release-nextgen-20251011

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.

@ti-chi-bot ti-chi-bot Bot merged commit 5541db5 into pingcap:master Nov 6, 2025
29 checks passed
@ti-chi-bot

Copy link
Copy Markdown
Member

@D3Hunter: new pull request created to branch release-nextgen-20251011: #64326.

Details

In response to this:

/cherry-pick release-nextgen-20251011

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/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants