Mryange opened a new pull request, #71081: URL: https://github.com/apache/doris/pull/71081
### Background The BE tracks active load channels, Stream Load contexts, and query result buffers in maps. Metric hooks export their entry counts, while the load channel uses its open state when deciding whether it has finished. ### What problem does this PR solve? Issue Number: None Related PR: #1954 (introduced the load-channel open flag), #3246 (added the container-size metric hooks) PR Type: Bugfix Problem Summary: ThreadSanitizer reported races between concurrent opens of one load channel and between metric collection and insertion or removal of map entries. Protect the open flag with the channel mutex and publish atomic entry counts from the existing map critical sections. ### Details - **Frequency:** Intermittent when concurrent opens target one load channel or metrics are collected while a map changes. - **Root cause:** The open flag was accessed outside the channel lock. Three metric hooks read map sizes outside the locks used by the writers. - **Why existing tests missed it:** Load channel and result buffer unit tests exercise lifecycle outcomes. The duplicate-load-ID regression tests request failure and row counts. These assertions do not detect unsynchronized memory access. - **Fix:** Check the open flag and the tablet channel map under one lock. Refresh the metric snapshots under the corresponding map locks, including timeout and bulk cancellation, so the metric callbacks can read counts without acquiring manager locks. - **Other paths and branches:** The fix covers ordinary and incremental open, Stream Load registration and removal, and MySQL and Arrow Flight buffer creation and cleanup. The same unsynchronized accesses exist on branch-4.1 and branch-4.2. ### Testing Extended existing BE unit tests with count assertions for ordinary cancellation and Arrow Flight bulk cancellation. The updated tests and a fresh ThreadSanitizer run are pending. ### Release note None ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Partially verified: BE unit tests and ThreadSanitizer have not run on the patch. ### AI Disclosure - Tool: OpenAI Codex (GPT-6) - Generated: Code, test assertions, and description - Human review: not stated -- 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]
