Skip to content

branch-4.1: [fix](be) Add missing SCOPED_ATTACH_TASK in download and move_dir callbacks#62401

Merged
yiguolei merged 1 commit intoapache:branch-4.1from
kaka11chen:fix_SCOPED_ATTACH_TASK
Apr 13, 2026
Merged

branch-4.1: [fix](be) Add missing SCOPED_ATTACH_TASK in download and move_dir callbacks#62401
yiguolei merged 1 commit intoapache:branch-4.1from
kaka11chen:fix_SCOPED_ATTACH_TASK

Conversation

@kaka11chen
Copy link
Copy Markdown
Contributor

@kaka11chen kaka11chen commented Apr 11, 2026

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

cherry-pick #62403

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

…lbacks

Issue Number: close #xxx

Problem Summary:
  download_callback() and move_dir_callback() in task_worker_pool.cpp use
  SnapshotLoader/CloudSnapshotLoader to perform HDFS downloads and file
  moves, but do not attach the MemTracker to the thread context via
  SCOPED_ATTACH_TASK. This causes memory orphan check failures when these
  callbacks allocate memory through HDFS operations, as the allocations
  are not tracked by any MemTrackerLimiter.

  The parallel upload_callback() already has SCOPED_ATTACH_TASK correctly.

  Fix: Add SCOPED_ATTACH_TASK(loader->resource_ctx()) in all four missing
  locations:
  - download_callback(StorageEngine&): remote_http_download branch
  - download_callback(StorageEngine&): broker download branch
  - download_callback(CloudStorageEngine&): cloud download branch
  - move_dir_callback(StorageEngine&): local move branch
Copilot AI review requested due to automatic review settings April 11, 2026 15:18
@kaka11chen kaka11chen requested a review from yiguolei as a code owner April 11, 2026 15:18
@kaka11chen
Copy link
Copy Markdown
Contributor Author

run buildall

@Thearas
Copy link
Copy Markdown
Contributor

Thearas commented Apr 11, 2026

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes memory tracking in BE agent task callbacks by attaching the SnapshotLoader/CloudSnapshotLoader ResourceContext to the current thread via SCOPED_ATTACH_TASK, preventing “orphan” memory allocations during snapshot download/move operations.

Changes:

  • Attach task resource context in download_callback(StorageEngine&) for both remote HTTP snapshot downloads and broker-based downloads.
  • Attach task resource context in download_callback(CloudStorageEngine&) for broker-based cloud downloads.
  • Attach task resource context in move_dir_callback(StorageEngine&) before performing the local snapshot move.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 0.00% (0/4) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.31% (26193/36731)
Line Coverage 54.24% (277050/510806)
Region Coverage 51.53% (230092/446478)
Branch Coverage 52.92% (99464/187957)

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@morningman morningman changed the title [fix](be) Add missing SCOPED_ATTACH_TASK in download and move_dir callbacks branch-4.1: [fix](be) Add missing SCOPED_ATTACH_TASK in download and move_dir callbacks Apr 13, 2026
@yiguolei yiguolei merged commit 89a1449 into apache:branch-4.1 Apr 13, 2026
35 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants