Skip to content

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

Merged
ti-chi-bot[bot] merged 2 commits intopingcap:release-nextgen-20251011from
ti-chi-bot:cherry-pick-67612-to-release-nextgen-20251011
Apr 10, 2026
Merged

pkg/dxf: avoid misleading error log on context cancel (#67612)#67674
ti-chi-bot[bot] merged 2 commits intopingcap:release-nextgen-20251011from
ti-chi-bot:cherry-pick-67612-to-release-nextgen-20251011

Conversation

@ti-chi-bot
Copy link
Copy Markdown
Member

@ti-chi-bot ti-chi-bot commented Apr 10, 2026

This is an automated cherry-pick of #67612

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
    • Updated task execution logging to treat context cancellations as informational events instead of errors, reducing misleading error entries.
    • Improves log clarity and decreases false-positive alerts in monitoring, making it easier to distinguish genuine failures from expected cancellations.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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. type/cherry-pick-for-release-nextgen-20251011 labels Apr 10, 2026
@ti-chi-bot
Copy link
Copy Markdown
Member Author

@D3Hunter This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot ti-chi-bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. type/cherry-pick-for-release-nextgen-20251011 labels Apr 10, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 10, 2026

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

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

@ti-chi-bot ti-chi-bot Bot added do-not-merge/cherry-pick-not-approved size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 10, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 958e2383-fbfd-4d4b-9b47-26c96ccd8417

📥 Commits

Reviewing files that changed from the base of the PR and between ade13f7 and a194b3c.

📒 Files selected for processing (1)
  • pkg/disttask/framework/taskexecutor/task_executor.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/disttask/framework/taskexecutor/task_executor.go

📝 Walkthrough

Walkthrough

Changed logging in BaseTaskExecutor.Run so that when runSubtask returns a context-canceled error it is logged at Info with a short message; other runSubtask errors continue to be logged as Error via sampleLogger.

Changes

Cohort / File(s) Summary
Error logging change
pkg/disttask/framework/taskexecutor/task_executor.go
In BaseTaskExecutor.Run, branch logging on context-cancellation: use sampleLogger.Info("subtask run canceled by context", llog.ShortError(err)) for context-canceled errors; retain sampleLogger.Error("run subtask failed", zap.Error(err)) for other errors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

size/XS

Suggested reviewers

  • Benjamin2037
  • joechenrh

Poem

🐰 I hopped through code with careful paws,
Found canceled tasks deserve applause.
Not every stop is an error cry —
Sometimes it's just a soft "goodbye". 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title references 'pkg/dxf' but the actual change is in 'pkg/disttask/framework/taskexecutor'. The title is misleading about the package affected. Update the title to 'pkg/disttask: avoid misleading error log on context cancel' to accurately reflect the changed package.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description covers the problem, solution, and checklist adequately. It explains the context-cancellation error handling and marks testing as unnecessary due to log-only changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/disttask/framework/taskexecutor/task_executor.go`:
- Around line 387-393: The code incorrectly references e.sampleLogger which
doesn't exist on BaseTaskExecutor; replace both uses of e.sampleLogger in the
context-canceled and error branches with the existing logger field e.logger so
logging remains consistent with the struct; update the two calls that currently
call e.sampleLogger.Info(...) and e.sampleLogger.Error(...) to call
e.logger.Info(...) and e.logger.Error(...) respectively in the Run/execute path
where llog.IsContextCanceledError(err) is checked.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1103c7e0-c678-4439-b28a-ad002a344b3f

📥 Commits

Reviewing files that changed from the base of the PR and between a8ad696 and ade13f7.

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

Comment thread pkg/disttask/framework/taskexecutor/task_executor.go
… cherry-pick-67612-to-release-nextgen-20251011

# Conflicts:
#	pkg/disttask/framework/taskexecutor/task_executor.go
@ti-chi-bot ti-chi-bot Bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 10, 2026
@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 10, 2026
@D3Hunter
Copy link
Copy Markdown
Contributor

/unhold

@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 10, 2026
@D3Hunter
Copy link
Copy Markdown
Contributor

/retest

Copy link
Copy Markdown
Collaborator

@Benjamin2037 Benjamin2037 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot Bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Apr 10, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 10, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, 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 Apr 10, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 10, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-10 07:57:14.005087377 +0000 UTC m=+1115839.210447434: ☑️ agreed by D3Hunter.
  • 2026-04-10 07:58:51.7048138 +0000 UTC m=+1115936.910173857: ☑️ agreed by Benjamin2037.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release-nextgen-20251011@0803391). Learn more about missing BASE report.

Additional details and impacted files
@@                      Coverage Diff                      @@
##             release-nextgen-20251011     #67674   +/-   ##
=============================================================
  Coverage                            ?   71.8532%           
=============================================================
  Files                               ?       1833           
  Lines                               ?     493072           
  Branches                            ?          0           
=============================================================
  Hits                                ?     354288           
  Misses                              ?     115460           
  Partials                            ?      23324           
Flag Coverage Δ
unit 71.8532% <100.0000%> (?)

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

Components Coverage Δ
dumpling 56.3493% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 46.5504% <0.0000%> (?)
🚀 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.

@ti-chi-bot ti-chi-bot Bot merged commit a31d609 into pingcap:release-nextgen-20251011 Apr 10, 2026
18 checks passed
@ti-chi-bot ti-chi-bot Bot deleted the cherry-pick-67612-to-release-nextgen-20251011 branch April 10, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. 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. type/cherry-pick-for-release-nextgen-20251011

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants