stinger1206 opened a new pull request, #67276:
URL: https://github.com/apache/doris/pull/67276
### What problem does this PR solve?
Issue Number: close #66895
Related PR: apache/brpc#3291
Problem Summary:
Follow-up to #64040 (backport of apache/brpc#2949). That fix made
`Agent::~Agent()`
safe by using a `weak_ptr` for `Agent::combiner`, but `~AgentCombiner()`
still calls
`clear_all_agents()`. When the last `shared_ptr` to the combiner is released
while
another thread is exiting, the TLS agents' `weak_ptr`s are already expired:
`~Agent`
skips `commit_and_erase()` and leaves its `LinkNode` in `_agents`, then the
`ThreadBlock` is freed - and `clear_all_agents()` walks that freed TLS
storage,
causing a heap-use-after-free. In production this shows up as SIGSEGV in
`bvar::SeriesSampler::take_sample` (#66895).
Fix: port apache/brpc#3291 - `~AgentCombiner()` no longer traverses
`_agents`.
This is safe: `butil::LinkNode` has a trivial destructor and is never
dereferenced
when the list is torn down, and surviving agents observe `combiner.expired()
== true`
in `~Agent` and skip `commit_and_erase()`. There is no memory leak: agents
are freed
together with their `ThreadBlock` at thread exit. This closes the gap that
was
flagged during review of #64040.
### Release note
None
### Check List (For Author)
- Test
- [ ] Regression test
- [ ] Unit Test
- [x] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- Behavior changed:
- [x] No.
- [ ] Yes.
- Does this need documentation?
- [x] No.
- [ ] Yes.
Manual test:
1. Applied the patch on top of the existing
`brpc-1.4.0-fix-agent-combiner-thread-safety.patch` and rebuilt brpc 1.4.0
thirdparty + BE (4.1.3-based image).
2. Ran the same workload that previously triggered the crashes in #66895:
sustained high-EPS stream load while rewriting a ~40B-row table from
storage format V2 to V3 on the affected production cluster
(compute-storage coupled mode, 6 BE nodes, Kubernetes).
3. Before the fix: BEs crashed with SIGSEGV in
`bvar::SeriesSampler::take_sample` (two BEs independently, see issue).
After the fix: the production cluster has been running stable for 2 days
with the patch applied - no recurrence of the SIGSEGV.
### Check List (For Reviewer who merge this PR)
- Confirm the release note
- Confirm test cases
- Confirm document
- Add branch pick label
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]