Skip to content

branch-4.1: [fix](be) Initialize bthread context key before first use - #67722

Merged
yiguolei merged 1 commit into
apache:branch-4.1from
sollhui:pick-67580-branch-4.1
Sep 10, 2026
Merged

yiguolei merged 1 commit into
apache:branch-4.1from
sollhui:pick-67580-branch-4.1

Conversation

@sollhui

@sollhui sollhui commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Backport #67580 to branch-4.1.

A bthread could create its ThreadContext before its key was initialized. Later key creation changed the key version, causing context lookup to return null and scoped memory-tracker cleanup to crash. Initialize the key once before first use and retain it for the process lifetime.

The conflict in thread_context.cpp was resolved by retaining the branch-4.1 function layout. The added and removed lines match the original PR.

Release note

Fix a potential BE crash during scoped memory-tracker cleanup caused by bthread context key initialization.

Check List (For Author)

  • Test: Compilation and tests skipped as requested. clang-format 16 and git diff --check passed.
  • Behavior changed: Yes; initialize the bthread context key before first use and preserve its process lifetime.
  • Does this need documentation: No.

@sollhui
sollhui requested a review from yiguolei as a code owner September 9, 2026 08:56
@hello-stephen

Copy link
Copy Markdown
Contributor

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?

@sollhui

sollhui commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (9/9) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.38% (31387/42196)
Line Coverage 58.63% (349486/596081)
Region Coverage 55.29% (291286/526818)
Branch Coverage 56.17% (131382/233906)

@yiguolei

yiguolei commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

skip buildall

@yiguolei
yiguolei merged commit b85792b into apache:branch-4.1 Sep 10, 2026
37 of 39 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

yiguolei pushed a commit that referenced this pull request Sep 10, 2026
…#67722)

### What problem does this PR solve?

Backport #67580 to branch-4.1.

A bthread could create its ThreadContext before its key was initialized.
Later key creation changed the key version, causing context lookup to
return null and scoped memory-tracker cleanup to crash. Initialize the
key once before first use and retain it for the process lifetime.

The conflict in thread_context.cpp was resolved by retaining the
branch-4.1 function layout. The added and removed lines match the
original PR.

### Release note

Fix a potential BE crash during scoped memory-tracker cleanup caused by
bthread context key initialization.

### Check List (For Author)

- Test: Compilation and tests skipped as requested. clang-format 16 and
git diff --check passed.
- Behavior changed: Yes; initialize the bthread context key before first
use and preserve its process lifetime.
- Does this need documentation: No.
@yiguolei yiguolei mentioned this pull request Oct 10, 2026
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.

3 participants