Skip to content

pkg/dxf: avoid misleading error log on context cancel#67612

Merged
ti-chi-bot[bot] merged 4 commits intopingcap:masterfrom
D3Hunter:fix-log
Apr 9, 2026
Merged

pkg/dxf: avoid misleading error log on context cancel#67612
ti-chi-bot[bot] merged 4 commits intopingcap:masterfrom
D3Hunter:fix-log

Conversation

@D3Hunter
Copy link
Copy Markdown
Contributor

@D3Hunter D3Hunter commented Apr 8, 2026

What problem does this PR solve?

Issue Number: ref #67631

Problem Summary:

When a distributed task subtask exits because the context is canceled, the executor currently logs it as a failure. This produces misleading error logs for expected cancellation paths.

What changed and how does it work?

In BaseTaskExecutor.Run, handle runSubtask errors by type:

  • If the error is a context-canceled error (llog.IsContextCanceledError(err)), log an info message.
  • Otherwise keep logging the error as before.

This preserves error visibility for real failures while reducing noisy/misleading logs for expected cancellations.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test. just changing log printing
    • 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

None

Summary by CodeRabbit

  • Bug Fixes
    • Reduced log noise for task execution: subtasks terminated due to context cancellation are now logged as informational messages rather than errors, making logs clearer and avoiding misleading error entries.

@ti-chi-bot ti-chi-bot Bot added the release-note-none Denotes a PR that doesn't merit a release note. label Apr 8, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai Bot commented Apr 8, 2026

@D3Hunter I've received your pull request and will start the review. I'll conduct a thorough review covering code quality, potential issues, and implementation details.

⏳ This process typically takes 10-30 minutes depending on the complexity of the changes.

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 8, 2026
@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

BaseTaskExecutor.Run now logs errors from runSubtask differently: context-cancellation errors (detected via llog.IsContextCanceledError) are logged at Info using llog.ShortError(err); all other errors continue to be logged as Error with zap.Error(err).

Changes

Cohort / File(s) Summary
Context-Cancellation Error Handling
pkg/dxf/framework/taskexecutor/task_executor.go
In BaseTaskExecutor.Run, distinguish runSubtask failures: log context-cancellation errors at Info using llog.ShortError(err); preserve Error logging (zap.Error(err)) for non-cancellation errors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

size/L

Suggested reviewers

  • hawkingrei
  • joechenrh
  • GMHDBJD

Poem

🐰 I hopped through logs with gentle care,
A canceled context drifted through the air,
I whispered "short and quiet" — soft and light,
No noisy error to disturb the night,
Carrots crunch, the run stays polite.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the package (pkg/dxf) and the specific change (avoiding misleading error logs on context cancellation), directly summarizing the main changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description follows the required template with all key sections completed: problem statement with issue reference, detailed explanation of changes, and appropriate test/documentation checkboxes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/dxf/framework/taskexecutor/task_executor.go (1)

394-399: Include cancellation details in the Info log.

At Line 396, the cancellation branch drops the error payload. Keep it at Info level, but include context (error and subtask ID) so cancellations remain diagnosable.

♻️ Suggested refinement
 		if err != nil {
 			// task executor keeps running its subtasks even though some subtask
 			// might have failed, we rely on scheduler to detect the error, and
 			// notify task executor or manager to cancel.
 			if llog.IsContextCanceledError(err) {
 				// to avoid the log being misleading when context is canceled.
-				e.logger.Info("meet context cancel when run subtask")
+				e.logger.Info("context canceled when running subtask",
+					zap.Int64("subtask-id", subtask.ID),
+					zap.Error(err))
 			} else {
 				e.logger.Error("run subtask failed", zap.Error(err))
 			}
 		} else {

As per coding guidelines, "Keep error handling actionable and contextual; avoid silently swallowing errors."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/dxf/framework/taskexecutor/task_executor.go` around lines 394 - 399, The
cancellation branch drops the error payload; update the
llog.IsContextCanceledError branch in the run-subtask handling (the code around
llog.IsContextCanceledError and e.logger.Info("meet context cancel when run
subtask")) to log the cancellation at Info level but include the error and
subtask identifier (e.g., subtask.ID or other subtask identifier variable) so
cancellations are diagnosable—replace the current e.logger.Info call with an
Info log that adds zap.Error(err) and a field for the subtask ID (or use
e.logger.InfoContext / With to attach context) while leaving non-cancellation
errors unchanged in e.logger.Error.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/dxf/framework/taskexecutor/task_executor.go`:
- Around line 394-399: The cancellation branch drops the error payload; update
the llog.IsContextCanceledError branch in the run-subtask handling (the code
around llog.IsContextCanceledError and e.logger.Info("meet context cancel when
run subtask")) to log the cancellation at Info level but include the error and
subtask identifier (e.g., subtask.ID or other subtask identifier variable) so
cancellations are diagnosable—replace the current e.logger.Info call with an
Info log that adds zap.Error(err) and a field for the subtask ID (or use
e.logger.InfoContext / With to attach context) while leaving non-cancellation
errors unchanged in e.logger.Error.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0ef1f38c-8a62-4ee9-b472-a1b1f2a13a00

📥 Commits

Reviewing files that changed from the base of the PR and between a69ecb8 and 6b875ac.

📒 Files selected for processing (1)
  • pkg/dxf/framework/taskexecutor/task_executor.go

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.6573%. Comparing base (a69ecb8) to head (4884fa5).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #67612        +/-   ##
================================================
+ Coverage   77.5859%   77.6573%   +0.0714%     
================================================
  Files          1980       1965        -15     
  Lines        547705     550852      +3147     
================================================
+ Hits         424942     427777      +2835     
- Misses       121953     123064      +1111     
+ Partials        810         11       -799     
Flag Coverage Δ
integration 41.3247% <0.0000%> (+6.9850%) ⬆️
unit 76.9214% <100.0000%> (+0.5857%) ⬆️

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

Components Coverage Δ
dumpling 61.5065% <ø> (ø)
parser ∅ <ø> (∅)
br 49.9700% <ø> (-10.5211%) ⬇️
🚀 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
Copy link
Copy Markdown
Contributor Author

D3Hunter commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@D3Hunter: 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.

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 added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 8, 2026
@D3Hunter
Copy link
Copy Markdown
Contributor Author

D3Hunter commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@D3Hunter: 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.

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.

@ingress-bot
Copy link
Copy Markdown

🔍 Starting code review for this PR...

Copy link
Copy Markdown

@ingress-bot ingress-bot left a comment

Choose a reason for hiding this comment

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

This review was generated by AI and should be verified by a human reviewer.
Manual follow-up is recommended before merge.

Summary

  • Total findings: 3
  • Inline comments: 3
  • Summary-only findings (no inline anchor): 0
Findings (highest risk first)

ℹ️ [Info] (1)

  1. Workaround comment explains logging effect but not cancellation contract (pkg/dxf/framework/taskexecutor/task_executor.go:395)

🧹 [Nit] (2)

  1. Cancellation log wording diverges from existing domain term (pkg/dxf/framework/taskexecutor/task_executor.go:396, pkg/dxf/framework/taskexecutor/task_executor.go:766)
  2. New cancellation log text introduces vocabulary drift (pkg/dxf/framework/taskexecutor/task_executor.go:396, pkg/dxf/framework/taskexecutor/task_executor.go:766)

Comment thread pkg/dxf/framework/taskexecutor/task_executor.go Outdated
Comment thread pkg/dxf/framework/taskexecutor/task_executor.go Outdated
Comment thread pkg/dxf/framework/taskexecutor/task_executor.go Outdated
@D3Hunter
Copy link
Copy Markdown
Contributor Author

D3Hunter commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@D3Hunter: 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.

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 Author

D3Hunter commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@D3Hunter: 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.

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 Author

D3Hunter commented Apr 8, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 8, 2026

@D3Hunter: 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.

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 Author

D3Hunter commented Apr 9, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 9, 2026

@D3Hunter: 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.

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 added the lgtm label Apr 9, 2026
@D3Hunter
Copy link
Copy Markdown
Contributor Author

D3Hunter commented Apr 9, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 9, 2026

@D3Hunter: 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.

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 Author

D3Hunter commented Apr 9, 2026

/approve

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 9, 2026

[APPROVALNOTIFIER] This PR is APPROVED

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

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 the approved label Apr 9, 2026
@D3Hunter
Copy link
Copy Markdown
Contributor Author

D3Hunter commented Apr 9, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 9, 2026

@D3Hunter: 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.

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 Author

D3Hunter commented Apr 9, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 9, 2026

@D3Hunter: 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.

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
Member

/retest

1 similar comment
@D3Hunter
Copy link
Copy Markdown
Contributor Author

D3Hunter commented Apr 9, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 9, 2026

@D3Hunter: 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.

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
Member

/retest

1 similar comment
@D3Hunter
Copy link
Copy Markdown
Contributor Author

D3Hunter commented Apr 9, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 9, 2026

@D3Hunter: 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.

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
Member

/retest

1 similar comment
@D3Hunter
Copy link
Copy Markdown
Contributor Author

D3Hunter commented Apr 9, 2026

/retest

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 9, 2026

@D3Hunter: 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.

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 7968513 into pingcap:master Apr 9, 2026
35 checks passed
@D3Hunter D3Hunter deleted the fix-log branch April 10, 2026 01:01
@D3Hunter
Copy link
Copy Markdown
Contributor Author

/cherry-pick release-nextgen-202603

@D3Hunter
Copy link
Copy Markdown
Contributor Author

/cherry-pick release-nextgen-20251011

@ti-chi-bot
Copy link
Copy Markdown
Member

@D3Hunter: new pull request created to branch release-nextgen-202603: #67673.

Details

In response to this:

/cherry-pick release-nextgen-202603

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 pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 10, 2026
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-20251011: #67674.
But this PR has conflicts, please resolve them!

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.

6 participants