morningman opened a new pull request, #71322:
URL: https://github.com/apache/doris/pull/71322

   ### Background
   
   BE pipeline operators queue and recycle data blocks, while the load and HTTP 
services coordinate worker shutdown. The backend also parses packed strings, 
serializes aggregate states for distributed queries, and tracks memory used by 
indexes and Python workers. Several of those paths rely on the C++ standard 
library or operating system for resource handling.
   
   ### What problem does this PR solve?
   
   Issue Number: #71314
   Related PR: #71315 (combined reference patch), #71292 (adjacent point-query 
changes)
   PR Type: Bugfix
   
   Problem Summary:
   
   Address crashes, shutdown hangs, and platform-dependent failures that 
surfaced when running BE unit tests on macOS with ASAN. The fixes keep owners 
alive during teardown, check point-query schema invariants before indexing, and 
pass the right string representation to each reader. The profiling, Python UDF 
memory, and certificate lookup paths now handle standard macOS facilities.
   
   ### Details
   
   - **Change map:** 107 additions and 33 deletions in BE code, plus 162 
additions and one deletion in tests.
     1. Capture the exchanger and release queued blocks while shared-state 
counters are live.
     2. Use the string set iterator’s `StringRef` for aggregate output and 
serialization. Add a round-trip test.
     3. Give `sscanf` a bounded, NUL-terminated copy of each accepted ISO date 
string.
     4. Add the hidden delete-sign column to the synthetic point-query schema.
     5. Count SNII heap buffers based on where each string stores its data.
     6. Read the current executable argument via `_NSGetArgv()` on macOS.
     7. Read Python worker RSS with `proc_pidinfo` on macOS and exercise valid 
and invalid PIDs.
     8. Append `/etc/ssl/cert.pem` to the backend’s default CA search list.
     9. Synchronize the load-stream count with stream erasure and destruction.
     10. Schedule libevent loop exit so it works before dispatch starts. Add a 
deterministically ordered test.
     11. Check the delete-sign index for both tuple shapes before indexing the 
schema.
   - **Frequency:** The memory and platform issues reproduce on the affected 
macOS paths. The load teardown abort and HTTP shutdown hang depend on thread 
timing. The new HTTP test forces shutdown to request exit before dispatch.
   - **Root cause:** Exchange teardown followed the owning pointer during 
destruction, and load teardown observed the count mid-erasure. Libevent clears 
a loop-break request at dispatch startup. The expression paths read iterator 
values or packed column strings with the wrong type or termination. The 
remaining paths assumed a valid schema index, libstdc++ inline string capacity, 
or Linux filesystem conventions.
   - **Why existing tests missed it:** The affected aggregate, date, exchange, 
and SNII tests relied on Linux library behavior. SQL suites for the aggregate, 
date, and point-lookup paths exercise valid queries. They leave invalid 
synthetic schemas and service shutdown ordering to BE unit tests. The prior 
HTTP tests did not control stop-before-dispatch order.
   - **Fix:** Handle ownership and synchronization where the objects are 
destroyed. Use bounded input and explicit schema checks at the existing read 
sites. Select the process APIs by platform and add the CA path as a fallback.
   - **Other paths and branches:** The two string aggregate variants share the 
corrected implementation. Point-query checks cover initialization with and 
without a projected delete-sign slot. Release snapshots 3.1 through 4.2 share 
the unchecked point-query, load count, pprof, loop-break, and CA-list patterns. 
The date path appears on 3.1 through 4.2. The affected local exchanger and 
string aggregates appear on 4.0 through 4.2. Python worker RSS affects 4.1 and 
4.2. SNII heap charging affects 4.2. The standalone `CmdlineAction` and cloud 
service retain separate platform paths.
   - **Configs and defaults:** The runtime-mutable `ca_cert_file_paths` list 
appends `/etc/ssl/cert.pem` after the three existing candidates. A configured 
list still takes precedence.
   - **Behavior change:** An invalid point-query schema fails at the invariant 
check. macOS can retrieve the executable argument and worker RSS, and the BE 
can discover the added system CA bundle.
   
   ### Testing
   
   - The original macOS ASAN runs reproduced the aggregate and date parser 
overreads and the local exchange crash. For the point-query regression, both 
tuple shapes hit the out-of-bounds read before the guard. The HTTP shutdown 
test stalled at worker join with the old implementation.
   - clang-format 16, the BE build hygiene gates, and clang-tidy passed on the 
split candidate. The standalone macOS ASAN build and the ordered and shuffled 
suite runs are in progress.
   
   ### Release note
   
   Fixed BE shutdown races and memory errors in query execution. On macOS, BE 
profiling can resolve the executable argument and Python UDF workers report 
resident memory. The BE can also discover system certificates under 
`/etc/ssl/cert.pem`.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: Yes (add a `ca_cert_file_paths` entry with 
its four defaults to the English and Chinese dev BE configuration references in 
apache/doris-website)
   - Pre-submission status: Not ready: standalone macOS ASAN build and focused 
runs in progress
   
   ### AI Disclosure
   
   - Tool: Claude Code (Claude Opus 5.5) for the original changes and Codex 
(GPT-6) for the split, follow-up, and description.
   - Generated: code and tests in the individual fixes, the shared-state 
teardown follow-up, and this description.
   - Human review: Not stated for the final PR candidate.
   
   


-- 
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]

Reply via email to