gavinchou opened a new pull request, #68522: URL: https://github.com/apache/doris/pull/68522
### What problem does this PR solve? Issue Number: N/A Related PR: N/A Problem Summary: Cloud ASAN UT could finish every gtest case and then crash during process teardown in MBvarLatencyRecorderWithStatus::ScheduledLatencyUpdater::update while accessing a bvar MultiDimension map. One observed failure is TeamCity build 1055210: http://43.132.222.7:8111/buildConfiguration/Doris_DorisCloudUt_CloudUt/1055210 The investigation showed that this is a lifecycle race in the Doris wrapper rather than an FDB or brpc data-path failure: 1. The test binary reached global test teardown before the crash, and the failing thread was the bthread TimerThread. 2. ScheduledLatencyUpdater keeps a raw pointer to its parent and periodically reads the parent recorder map, mutexes, and status bvars. 3. With the implicit parent destructor, those dependencies begin destruction before recorder_ releases its updater objects. 4. In brpc 1.4.0, bthread_timer_del returns 1 when a callback is already running and does not join it. The old stop path ignored that return value. The fix serializes timer start, reschedule, and stop; tracks whether a callback is scheduled or running; waits for an active callback to finish; and explicitly drains every updater at the beginning of parent destruction. The parent map lock is released before waiting so a callback can finish its dimension lookup without deadlocking. This guarantees that callbacks no longer access the parent before its members are destroyed. A deterministic regression test blocks an update callback, destroys the parent concurrently, verifies that destruction waits, then releases the callback. ### Release note None ### Check List (For Author) - Test - [x] Regression test - [x] Unit Test - local_to_dev Cloud ASAN bvars_test: 2/2 passed, ret=0 - local_to_dev Cloud ASAN meta_service_test: 273/273 passed, ret=0; normal process teardown with no ASAN failure - Clang 20 clang-tidy using the Cloud ASAN compile database: passed - Behavior changed: - [x] No. - Does this need documentation? - [x] No. ### 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]
