Repository navigation
Use an 8 MiB stack for the suggestion-loading thread on Darwin - #129026
Conversation
For `LocalConnection` (interactive `clickhouse-local`) the whole suggestion
query runs in-process in `Suggest::loading_thread`: analyzer, planner, and the
regexp JIT that `extractAll(word, '[\\w_]{2,}')` triggers during header
evaluation. The thread was a plain `std::thread`, which macOS gives a 512 KiB
stack, and LLVM codegen does not cooperate with `checkStackSize`, so it ran
into the guard page (`EXC_BAD_ACCESS "Thread stack size exceeded"` in thread
`Suggest`). This killed the `clickhouse-local` under test in
`Fast test (arm_darwin)` for `05024_local_listener_survives_handler_exception`
(curl rc 56) and `04892_client_dialect_command` (`spawn id not open`) on
PRs ClickHouse#95355, ClickHouse#88234, ClickHouse#117004 and ClickHouse#117636: 26 of 26 macOS crash reports of those
jobs show this stack.
ClickHouse#107033 gave the global thread pool and the server pools
`DEFAULT_THREAD_STACK_SIZE` via `ThreadWithStackSize`, and 3510173 did
the same for the `clickhouse-local` listener pool; the suggestion loader was
missed. Use `ThreadWithStackSize` for it on Darwin; other platforms keep
`std::thread`, whose default stack follows `RLIMIT_STACK`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep the original 'Words are fetched asynchronously.' line and state the Darwin stack need in one line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding) plus my own review (3 nits, all in the PR description, fixed before publishing).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261103-143900 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20261103-141400 |
|
cc @azat @Algunenano, could you review this and add the |
|
Workflow [PR], commit [1f98695] Summary: ✅
AI ReviewSummaryThe PR gives the Darwin suggestion-loading thread an 8 MiB stack through Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units23 translation units recompiled, 133 s compile time in total, 23 of them have a recent master baseline. |
460888d
Related: #88234
Related: #107033
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
clickhouse-localandclickhouse-clienton macOS now load command-line suggestions in a thread with an 8 MiB stack, like their thread-pool threads, so the suggestion query of an interactiveclickhouse-localcan no longer overflow the 512 KiB default thread stack during JIT compilation.Description
Requested in #88234 (comment).
Fast test (arm_darwin)failed05024_local_listener_survives_handler_exception(return code: 56) and04892_client_dialect_command(spawn id exp6 not open) in 4 PRs in the last 10 days (1, 2, 3, 4). Both are the same event: theclickhouse-localunder test dies withEXC_BAD_ACCESS "Thread stack size exceeded"in threadSuggest. All 26 macOS crash reports show:Suggest::fetch->LocalConnection::sendQuery-> planner ->extractAll->getRegexpJITMatcher-> LLVMAArch64AsmPrinter.For
LocalConnectionthe suggestion query is analyzed and planned inSuggest::loading_thread, a plainstd::thread, which macOS gives 512 KiB, and LLVM codegen does not callcheckStackSize. #107033 gave the global pool and the server poolsDEFAULT_THREAD_STACK_SIZEthroughThreadWithStackSize; this thread was missed. It now usesThreadWithStackSizeon Darwin; other platforms are unchanged.Validation on Linux, where
ulimit -ssets the default thread stack: the loader fails withTOO_DEEP_RECURSIONat 296 KiB and loads at 312 KiB; the main thread runs at 256 KiB. A-DOS_DARWINbuild of the same member shape gets an 8 MiB stack even underulimit -s 512. 05024 and 04892 passed 50/50. No test is added: the crash is Darwin-only and frame-size dependent; the existing interactive darwin tests cover it.Workflow [PR]
Sync PR [sync-upstream/pr/129026]
Version info
26.11.1.1266-master(included in26.11and later)