Mryange opened a new pull request, #70925: URL: https://github.com/apache/doris/pull/70925
### Background Cloned expression contexts share the same expression tree. Each clone initializes its own thread-local function state, while the original context initializes fragment-local state. ### What problem does this PR solve? Issue Number: None Related PR: #39912 (introduced the IN argument flag) PR Type: Bugfix Problem Summary: Concurrent opens of cloned contexts can race with each other or with expression evaluation. TSan reported reads and writes to the IN predicate's constant-argument flag. Compute the flag during preparation and remove the shared open-completion flag. ### Details - **Change map:** 324 changed lines in production C++ and 74 in BE test code. Production changes const-qualify the affected interfaces and confine initialization writes to fragment open. Test changes update overrides and lifecycle assertions. - **Frequency:** Intermittent when clones open or a clone opens while another context evaluates the same expression. - **Root cause:** Thread-local opens write fields on expression nodes shared by all contexts. Readers use the IN flag to select which children to evaluate. - **Why existing tests missed it:** MockInExprTest exercises construction and the IN regression suite checks SQL results including NULL semantics. These checks do not assert concurrent access to the same expression node. - **Fix:** Set the IN argument flag after child preparation, remove the node-level open flag, and let DeletePredicate open its children. Keep fragment-only writes under the original context's initialization path, with documented temporary casts at the const open boundary. - **Other paths and branches:** The open flag is removed across expression subclasses. Both 4.1 and 4.2 contain the IN flag write and have conflicts with this patch. - **Behavior change:** DeletePredicate now opens its children during initialization. ### Testing ASAN BE and BEUT compiled and linked successfully with `BUILD_TYPE=ASAN bash build.sh --be -j48` and `bash run-be-ut.sh -j48`. Clang-format 16, build hygiene, and changed-line clang-tidy checks passed using the BE and BEUT compilation databases. Tests were not executed. ### Release note Avoid data races during expression initialization for cloned execution contexts. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Partially verified: runtime tests were not executed ### AI Disclosure - Tool: Codex - Generated: Code changes, BEUT compatibility edits, and PR description. - Human review: The author reviewed the implementation plan and the final diff and approved submission. -- 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]
