Uh oh!
There was an error while loading. Please reload this page.
[fix](be) Serialize bvar TLS agent lifetime updates - #67692
Closed
hello-stephen wants to merge 1 commit into
Closed
Conversation
### What problem does this PR solve? Issue Number: N/A Related PR: apache#66977 Problem Summary: Concurrent destruction of a bvar combiner and TLS agent teardown can access the same std::weak_ptr at the same time. This violates the weak_ptr concurrency contract and can corrupt its shared ownership state, which was observed as an ASAN heap-use-after-free in TableRpcQpsRegistryTest.ConcurrentRecordAndCleanup. Serialize accesses to each agent's weak_ptr while using an atomic attachment flag for the reducer update hot path. Amplify the existing concurrent cleanup test to exercise repeated cross-thread combiner destruction. ### Release note None ### Check List (For Author) - Test: - ClangFormat 16 check - Build hygiene check - Applied all brpc patches in build order - GCC 15 C++17 syntax instantiation of the patched AgentCombiner - Behavior changed: No - Does this need documentation: No
hello-stephen
requested review from
gavinchou, morningman and yiguolei
as code ownersSeptember 9, 2026 02:56
hello-stephen
commented
Sep 9, 2026
ContributorAuthor
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
hello-stephen
commented
Sep 9, 2026
ContributorAuthor
run buildall |
hello-stephen
commented
Sep 9, 2026
ContributorAuthor
hello-stephen
commented
Sep 9, 2026
ContributorAuthor
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
hello-stephen
commented
Sep 9, 2026
ContributorAuthor
Closing this PR as requested. The diagnosis will be moved to Jira for an owner-led fix because this draft touches the vendored brpc patch and needs upstream/domain-owner review before selecting the repair boundary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: N/A
Related PRs: #64040, #66977
Problem Summary:
BE UT build 1040681 hit an ASAN heap-use-after-free in
TableRpcQpsRegistryTest.ConcurrentRecordAndCleanup. The failure occurs while the cleanup thread destroys abvar::Adderand another thread tears down its TLS agent.The bvar lifetime patch stores each agent's combiner in a
std::weak_ptr.Agent::~Agent()may calllock()at the same time asAgentCombiner::clear_all_agents()callsreset()on that same weak pointer. Concurrent non-const access to the sameweak_ptrobject is not safe and can corrupt the shared ownership control block.This PR:
The failing build was for #67679 at
094f6499cbcb58acfaf99f1d0f942454c871b9eb. That PR only changes zero-argument COUNT aggregate-state files and does not touch this registry or bvar. The unsafe weak-pointer implementation came from #64040; the registry cleanup path that exposed it was introduced by #66977.Release note
None
Check List (For Author)
AgentCombiner