Skip to content

Recognize an Emscripten/WebAssembly target - #112911

Merged
alexey-milovidov merged 11 commits into
masterfrom
wasm-target-scaffolding
Aug 4, 2026
Merged

alexey-milovidov merged 11 commits into
masterfrom
wasm-target-scaffolding

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

Adds OS_WASM/ARCH_WASM to the build system and the platform arms that go with them, so emcmake cmake configures this tree and the lower layers of it compile to wasm64. It is experimental and not in CI, like the Android and E2K targets; nothing here changes any platform that builds today.

The build system: arch and target detection, cmake/wasm/default_libs.cmake (the Emscripten sysroot already supplies libc, libc++, libc++abi, compiler-rt and a pthread implementation, so unlike the other platforms this one does not use -nodefaultlibs), emcc handling in cmake/tools.cmake (it knows its own target and drives wasm-ld itself), the set of libraries a sandbox cannot have, ucontext fibers for Boost.Context and the Linux resolver configuration for c-ares.

wasm64 rather than wasm32, because this tree assumes a 64-bit size_t and 64-bit pointers pervasively, from 1e12uz literals in Core/Defines.h to sizeof-equality static_asserts in ProfileEvents.

The platform arms: thread ids and names, waitForPid, malloc_usable_size, and stack traces — WebAssembly cannot walk its own call stack from user code and there is no libunwind for it. Signals get one capability macro, OS_HAS_SIGNAL_HANDLERS in base/defines.h, rather than a condition per call site; the timer-based query profiler follows it, since a per-thread timer has no way to deliver an expiry without signals.

Two fixes that are not WebAssembly-specific but block this configuration:

  • The USE_LIBFIU=0 branch of FailPoint.cpp is stale. It defines enablePauseFailPoint, wait and enableFromGlobalConfig, none of which the class declares any more, and omits notifyPauseAndWaitForResume, which it does. -DENABLE_LIBFIU=OFF does not build on any platform today.
  • atomicRename.cpp defines RENAME_NOREPLACE/RENAME_EXCHANGE unconditionally in its non-Linux branch, which collides with a libc that declares them without being able to honour them.

No warnings are disabled. -Weverything -Werror is untouched and WERROR is not weakened. The one diagnostic that came from a libc macro rather than from this code — musl spells stderr as #define stderr (stderr) — is suppressed at the single use, the way cmake/warnings.cmake prescribes.

Verification

With Emscripten 6.0.5:

  • the whole tree configures;
  • base/base/libcommon.a and src/libclickhouse_common_io.a build — 402 objects, confirmed as WebAssembly binaries with llvm-objdump — with the standard warning set and -Werror.

On Linux the full clickhouse binary builds and behaves identically to a build without this change: stack traces (symbolized, and system.errors.last_error_trace), the query profiler and thread naming are all unchanged.

What is deliberately left out

  • -Wunique-object-duplication fires 214 times across 16 headers (Interpreters/Context.h, Core/BaseSettings.h, Common/TargetSpecific.h, …) because Emscripten defaults to -fvisibility=hidden, which no other target here uses. Clearing it means giving those statics default visibility, which is its own change.
  • Everything above clickhouse_common_io has not been attempted.
  • A WebAssembly build additionally needs Build OpenSSL from portable C sources where there is no assembly #112863 (OpenSSL has no assembly for this target) and Do not require the patched libc++ to compile Common/Exception.cpp #112865 (Common/Exception.cpp cannot compile against a foreign libc++). Both are independent of this change and both have now been merged into master; the results above were measured with all three applied.

Related: #112863
Related: #112865
Related: #112866

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Added an experimental WebAssembly (wasm64, via Emscripten) target: emcmake cmake now configures the tree and the lower layers build. Also fixed -DENABLE_LIBFIU=OFF, which did not build on any platform.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Adds `OS_WASM`/`ARCH_WASM` to the build system and the platform arms that go with them, so
`emcmake cmake` configures this tree and the lower layers of it compile to `wasm64`. It is
experimental and not in CI, like the Android and E2K targets; nothing here changes any
platform that builds today.

The build system: arch and target detection, `cmake/wasm/default_libs.cmake` (the Emscripten
sysroot already supplies libc, libc++, libc++abi, compiler-rt and a pthread implementation,
so unlike the other platforms this one does not use `-nodefaultlibs`), `emcc` handling in
`cmake/tools.cmake` (it knows its own target and drives `wasm-ld` itself), the set of
libraries a sandbox cannot have, `ucontext` fibers for Boost.Context and the Linux resolver
configuration for c-ares.

`wasm64` rather than `wasm32`: this tree assumes a 64-bit `size_t` and 64-bit pointers
pervasively, from `1e12uz` literals in `Core/Defines.h` to sizeof-equality static_asserts in
ProfileEvents.

The platform arms: thread ids and names, `waitForPid`, `malloc_usable_size`, and stack traces
- WebAssembly cannot walk its own call stack from user code and there is no libunwind for it.
Signals get one capability macro, `OS_HAS_SIGNAL_HANDLERS` in `base/defines.h`, rather than a
condition per call site; the timer-based query profiler follows it, since a per-thread timer
has no way to deliver an expiry without signals.

Two fixes that are not WebAssembly-specific but block this configuration:

* The `USE_LIBFIU=0` branch of `FailPoint.cpp` is stale. It defines `enablePauseFailPoint`,
  `wait` and `enableFromGlobalConfig`, none of which the class declares any more, and omits
  `notifyPauseAndWaitForResume`, which it does. `-DENABLE_LIBFIU=OFF` does not build on any
  platform today.
* `atomicRename.cpp` defines `RENAME_NOREPLACE`/`RENAME_EXCHANGE` unconditionally in its
  non-Linux branch, which collides with a libc that declares them without being able to
  honour them.

No warnings are disabled: `-Weverything -Werror` is untouched, and the one diagnostic that
came from a libc macro rather than from this code - musl spells `stderr` as
`#define stderr (stderr)` - is suppressed at the single use, the way `cmake/warnings.cmake`
prescribes.

Verified with Emscripten 6.0.5. The whole tree configures. `base/base/libcommon.a` and
`src/libclickhouse_common_io.a` build - 402 objects, confirmed as WebAssembly binaries -
with the standard warning set and `-Werror`. On Linux the full `clickhouse` binary builds
and behaves identically: stack traces, the query profiler and thread naming all unchanged.

Two things still stand between this and a whole WebAssembly binary, both deliberately left
out. `-Wunique-object-duplication` fires 214 times across 16 headers because Emscripten
defaults to `-fvisibility=hidden`, which no other target here uses; clearing it means giving
those statics default visibility, which is its own change and not this one. And the rest of
the tree beyond `clickhouse_common_io` has not been attempted.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3cb7492]

Summary: ✅


AI Review

Summary

The PR adds an experimental Emscripten/wasm64 target, fences off unsupported lower-level runtime features, and fixes a few unrelated portability problems that blocked this configuration. I re-checked the current head against the live diff and the full prior discussion; the previously reported blockers are addressed in the code now, the remaining bot-authored open thread was resolved, and I did not find any new correctness, safety, or compatibility issues worth a fresh inline review comment.

Final Verdict

✅ No new findings on the current head.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 38/54 (70.37%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-build Pull request with build/testing/packaging improvement submodule changed At least one submodule changed in this PR. labels Aug 2, 2026
Comment thread cmake/arch.cmake Resolved
\`cmake/arch.cmake\` matched \`CMAKE_SYSTEM_PROCESSOR\` first and only fell
through to the \`Emscripten\` branch. That works with the default Emscripten
toolchain, which sets the processor to \`x86\` - a value none of the host-CPU
regexes claim - but it is fragile: \`-DEMSCRIPTEN_SYSTEM_PROCESSOR=x86_64\`
(or \`arm64\`) makes a WebAssembly configure select \`ARCH_AMD64\` instead, and
with it the host-only paths such as Boost.Context assembly and \`-march=\`
flags. Test the target name first, and correct the comment, which claimed
Emscripten leaves the processor as the host's.

Verified with Emscripten 6.0.5: \`ARCH_WASM\` is set both with the default
processor and with \`-DEMSCRIPTEN_SYSTEM_PROCESSOR=x86_64\`, and a native
configure is unchanged.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 AI review blocker addressed in 1988dcb4400.

The finding was right that the ordering is wrong, though not for the stated reason: Emscripten does not leave CMAKE_SYSTEM_PROCESSOR at the host value, it sets it to x86 (Platform/Emscripten.cmake), which none of the host-CPU regexes in cmake/arch.cmake match — so the default emcmake cmake did reach the ARCH_WASM branch. The comment in the file claiming otherwise was mine and was wrong.

It is still fragile, because the processor is user-overridable (-DEMSCRIPTEN_SYSTEM_PROCESSOR=x86_64), and then a WebAssembly configure really does select ARCH_AMD64. The target-name check now runs before every processor match, and the comment is corrected.

Verified with Emscripten 6.0.5: ARCH_WASM is set both with the default processor and with -DEMSCRIPTEN_SYSTEM_PROCESSOR=x86_64; a native configure still selects the host architecture.

Comment thread cmake/target.cmake Resolved
The option only ever had one working value. Turning it off did not select a
supported `wasm32` build - it dropped the ABI flags and left the tree, which
assumes a 64-bit `size_t` and 64-bit pointers throughout, to fail somewhere
unrelated later. Set the Memory64 flags unconditionally instead.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 AI review major addressed in efdaa808ad4: the WASM_MEMORY64 option is gone and the Memory64 ABI flags are set unconditionally. The knob had only one working value — turning it off produced a wasm32 configuration that this tree cannot support, so it was a way to defer the failure, not a supported choice.

Comment thread cmake/target.cmake Resolved
`clock_gettime_ns` throws `std::system_error` when the clock is rejected, so a clock id that
exists but does not work turns every timing call in the process into a throw. Emscripten has
two of them: `CLOCK_MONOTONIC_RAW` and `CLOCK_MONOTONIC_COARSE` are both defined and both
return EINVAL.

Both already have compile-time selection, and both miss this case for the same reason - they
test whether the macro is *defined*, which it is:

  * `STOPWATCH_DEFAULT_CLOCK` picks `CLOCK_MONOTONIC_RAW` under `#ifdef`.
  * `base/time.h` falls back for `CLOCK_MONOTONIC_COARSE` only under `#if !defined`. Some forty
    call sites pass that macro explicitly, so overriding it there covers all of them.

Extend the existing conditions rather than adding a runtime fallback. Retrying on a different
clock after EINVAL would mean silently serving a monotonic reading from `CLOCK_REALTIME`, and
elapsed times could then go negative across an NTP step - worse than the throw it avoids.

Measured with Emscripten 6.0.5, running the real headers under node: before, both resolve to
ids 4 and 6 and `clock_gettime` fails on each; after, both resolve to id 1 and succeed. On the
host, `CLOCK_MONOTONIC_RAW` is still selected and the preprocessed output of `base/time.h` is
byte-identical, so no other platform changes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Comment thread src/Common/memory.h Resolved
…ding

The only conflict was in `src/Common/FailPoint.cpp`: master has landed the
same adaptation of the `USE_LIBFIU=0` stubs to the renamed API that this
branch carried, and additionally made the query-reachable stubs throw
`SUPPORT_IS_DISABLED` instead of silently succeeding. Master's version is a
strict superset, so it is taken as-is.
The AI review blocker was right. `untrackMemory` only had a size for the
sized `operator delete` overloads on `OS_WASM`: the `malloc_usable_size`
branch was excluded, so every unsized delete freed the object while leaving
`CurrentMemoryTracker` incremented, which accumulates phantom memory and
eventually raises a false `MEMORY_LIMIT_EXCEEDED`.

The premise of the exclusion was wrong: Emscripten's musl-derived libc does
declare `malloc_usable_size` in `<malloc.h>` and its allocator implements it -
the header just was not being included, because the include was guarded on
`OS_LINUX`. Include it on `OS_WASM` as well and drop the exclusion.

Verified under Emscripten 6.0.5 that `malloc_usable_size` links and returns the
usable size for both `wasm32` and `-sMEMORY64=1`.
…ot serve

`ENABLE_WASMEDGE` was left on, so an `OS_WASM` configure still produced
`ch_contrib::wasmedge` - a host WebAssembly runtime, inside a WebAssembly
sandbox - and `dbms` would link it. Turn it off; `wasmtime`, the other engine,
is Rust and `ENABLE_RUST` already covers it.

Three more opt-outs are needed for `emcmake cmake` to configure at all now that
the tree has moved on:

- `ENABLE_SSH`: `libssh` needs raw sockets, and `contrib/libssh-cmake` fails
  with `Platform is not supported` because its config headers are pregenerated
  per platform.
- `ENABLE_PROTOBUF`: `protoc` has to run on the host, and the nested native
  configure at the bottom of the top-level `CMakeLists.txt` is handed `emcc` as
  its host compiler, which then rejects the empty target.
- `ENABLE_PARQUET`: Arrow and ORC hard-depend on the `protobuf` target.

Verified with Emscripten 6.0.5: `emcmake cmake` now configures and generates
cleanly, and `ninja clickhouse_common_io` builds.
`LONG_IS_A_DISTINCT_TYPE` was keyed off `!defined(__LP64__)`, but `wasm64`
defines `__LP64__` and still has `__INT64_TYPE__` as `long long int`, so a
64-bit `long` there matches neither `Int64` nor `Int32` - exactly the Darwin
situation, which the macro already handles. Without the `long` overloads,
`itoa` calls from `writeIntText` and `toString` were ambiguous.

The pointer width alone does not answer the question, so key the macro on the
platform instead.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Both AI review findings are addressed, and the merge conflict with master is resolved.

Blocker — unsized-delete memory accounting on OS_WASM (994b9195d0e). The finding was correct: with the malloc_usable_size branch excluded, every delete expression lowering to the size-unaware form freed the object while leaving CurrentMemoryTracker incremented.

The exclusion itself was based on a wrong premise of mine — Emscripten's musl-derived libc does declare malloc_usable_size in <malloc.h> and its allocator implements it. It was simply never visible, because the #include <malloc.h> in src/Common/memory.h is guarded on OS_LINUX. So the fix recovers the size rather than bypassing accounting: include the header on OS_WASM too and drop the !defined(OS_WASM) condition. Verified with Emscripten 6.0.5 that it links and returns the usable size for both wasm32 and -sMEMORY64=1.

Major — ENABLE_WASMEDGE (206aabcbe0a). Correct as well: a host WebAssembly runtime inside a WebAssembly sandbox. It is now forced off in the OS_WASM block. wasmtime, the other engine, is Rust, so ENABLE_RUST already covered it.

Re-running emcmake cmake against current master surfaced three more configure failures, fixed in the same commit: ENABLE_SSH (contrib/libssh-cmake fails with Platform is not supported; its config headers are pregenerated per platform), ENABLE_PROTOBUF (protoc must run on the host, and the nested native configure at the bottom of the top-level CMakeLists.txt is handed emcc as its host compiler), and ENABLE_PARQUET (Arrow and ORC hard-depend on the protobuf target).

Also 70635336e48: LONG_IS_A_DISTINCT_TYPE was keyed off !defined(__LP64__), but wasm64 defines __LP64__ and still has __INT64_TYPE__ as long long int — exactly the Darwin case the macro already handles — so itoa calls from writeIntText and toString were ambiguous.

On the reported blind spot: this was verified locally with Emscripten 6.0.5. emcmake cmake configures and generates cleanly, and ninja clickhouse_common_io builds to completion. The native Linux build of clickhouse_common_io is also still clean after the base/base/defines.h change.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112911&sha=c41e24cb553693def4ded9a8f8151a651dd80531&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

Job log: https://s3.amazonaws.com/clickhouse-test-reports/PRs/112911/c41e24cb553693def4ded9a8f8151a651dd80531/stateless_tests_amd_debug_parallel/job.log

The server disappeared mid-run at test 7326/12303, with 00090_union_race_conditions_1.sh in flight:

Hung check failed: server is not responding
Unable to locate any ClickHouse server process. It must have crashed or exited prematurely!
Stopping tests, terminating all processes...

The whole run then aborted with StopTesting, so there is no named failing test. The job carries the under-utilized RAM, under-utilized CPU labels. I could not find an open issue or PR tracking this.

This is unrelated to the changes here: every code path this PR touches on Linux is behind OS_WASM or OS_HAS_SIGNAL_HANDLERS (which is defined on Linux, so all of those guards fall through to exactly the code on master), the atomicRename.cpp change is inside the non-Linux #else branch, and the rest is build-system only. A git diff origin/master HEAD restricted to the source files confirms no behavioral difference for a Linux server build.

Comment thread base/base/defines.h Resolved
@groeneai

groeneai commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Investigated. There are two separate defects in the report, and neither is caused by this PR - your attribution is right, and the second one is why the report is empty.

1. Why the report has no evidence at all (the ERROR status, no test rows, no logs).

The run aborted at 09:58:52 and the job then hung for 2 h 17 min until praktika's own 9000 s timeout SIGKILLed it at 18:16:09. So clickhouse-test never returned, FTResultsProcessor never ran, and Result.create_from(files=CH.logs + debug_files, ...) at ci/jobs/functional_tests.py:1393 never executed. That is why result_stateless_tests_amd_debug_parallel.json carries files: [] and no clickhouse-server.err.log.zst / fatal.log / hung_check.log. The server death was not diagnosable from the artifacts because the artifact-collecting code was never reached.

The hang is in the hung-check teardown path:

  • tests/clickhouse-test:5320 prints Hung check failed, then calls print_c_stacktraces.
  • print_c_stacktraces -> get_stacktraces_from_lldb -> _ensure_lldb_installed (tests/clickhouse-test:1008), which is TEMPORARY scaffolding from 2b52028 that runs apt-get update + apt-get install -y lldb at runtime because the images ship gdb, not lldb. That follow-up never landed: ci/docker/stateless-test/Dockerfile:155-156 still copies /opt/gdb from cctools, and grep -rn lldb ci/docker/ on current master returns nothing. The apt output at 09:59:02 in the log is that helper firing.
  • Meanwhile kill_process_group had done killpg(SIGTSTP) at 09:58:52 followed by sleep 10 (tests/clickhouse-test:700-705), and the pgid it targeted was 00090_union_race_conditions_1.sh's. SIGTSTP stops the clickhouse-client children rather than killing them; the SIGTERM/SIGKILL at :739-745 are sent to a process group whose members are already stopped.
  • The runner is clickhouse-test ... | ts | tee -a test_result.txt under set -o pipefail (ci/jobs/functional_tests.py:137-140). A stopped-but-alive descendant still holds the inherited stdout, so ts/tee never see EOF and the pipeline never completes. Verified locally: with a writer that exits while an orphaned child keeps the inherited stdout open, the pipeline does not EOF (timeout returns 124).
  • Nothing bounds this, because on the plain stateless path global_time_limit == 0, so outer_timeout = None (ci/jobs/functional_tests.py:152). The flaky and targeted checks pass a positive limit and therefore do get a Shell.run timeout; the ordinary batches get none. Only the outer job timeout stops it, 2 h 17 min later, with a SIGKILL that destroys the report.

This is the generic failure mode, not something specific to your branch: any SERVER_DIED / hung-check / check_server_started abort in a non-time-limited stateless job takes this path. Unable to locate any ClickHouse server process appears in 55 rows across 12 distinct check names and 55 distinct commits in the last 30 days.

2. The server death itself. I cannot attribute it from this job, for the reason above - the err log and fatal.log were never uploaded, and Unable to locate any ClickHouse server process means print_c_stacktraces found no process to attach to, so there is no stack either. 00090_union_race_conditions_1.sh was in flight but is a witness, not evidence: at 09:58:47 the harness observed both that the server stopped answering and that no clickhouse-server process existed, i.e. it was gone before the check ran. under-utilized RAM, under-utilized CPU argues against host OOM, so I am not writing this off as infrastructure.

I found no open issue or PR for either half, matching what you saw.

I am opening a separate PR for defect 1: bound the teardown so the abort path cannot outlive the job, and remove the runtime apt-get from it. That also makes defect 2 diagnosable - with the logs and stacks actually attached, the next occurrence carries the evidence this one lost. I will link the PR here.

…HANDLERS`

`ThreadStatus` installed an alternative stack and rewrote the `SIGSEGV`
action on every thread, outside the new signal-capability fence. On a
target without signal delivery those calls can only no-op or warn, so
the whole `ThreadStack` machinery now follows `OS_HAS_SIGNAL_HANDLERS`,
the same way `QueryProfiler` and `SignalHandlers` do.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master (clean, no conflicts) and addressed the AI review finding: the alternative-signal-stack setup in src/Common/ThreadStatus.cpp is now fenced on OS_HAS_SIGNAL_HANDLERS (3cb7492ec0a).

The two stress reds at 70635336e48 are unrelated to this PR — every Linux-visible path here is behind OS_WASM or OS_HAS_SIGNAL_HANDLERS (defined on Linux), so a Linux build behaves identically to master:

@groeneai

groeneai commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

The single hung row is not an analyzer query. hung_check.log contains exactly one Row 1: in the processlist:

query:        SELECT x, y, z FROM odbc('[HIDDEN]', 'test%5', 't') ORDER BY x ASC NULLS FIRST
elapsed:      491.142501
is_cancelled: 1
read_rows:    0
log_comment:  01086_odbc_roundtrip.sh-test_5
thread_ids:   [20568,12028]

The QueryTreePassManager and executeASTFuzzerQueries frames are in the file, but not in that dump. Of the 24 lines carrying either symbol, 23 sit in the Top messages not matching their format strings section at the end (logged exception stacks of unrelated fuzzed queries), and the remaining one is executeASTFuzzerQueries in this query's waiter thread 12028, which is only blocked in CompletedPipelineExecutor::execute. The processlist dump is lines 15 to 119, and QueryTreePassManager does not occur in that range.

The worker thread 20568 is where it is stuck:

poll <- Poco::Net::SocketImpl::receiveBytes <- HTTPSession::receive
     <- HTTPResponse::read <- HTTPClientSession::receiveResponse
     <- ReadWriteBufferFromHTTP::callImpl <- initialize
     <- ReadWriteBufferFromHTTP::doWithRetries <- nextImpl
     <- BinaryRowInputFormat::readRow <- StorageURLSource::generate

Timeline for query id d3977f88-6dec-459a-b3cb-a8c2d6a3c4a6 from clickhouse-server.stress.log:

  • 00:54:37.512 query starts, max_execution_time = 10000 ms armed.
  • 00:54:47.596 CancellationChecker: Cancelling the task because of the timeout, so is_killed is set (hence is_cancelled: 1).
  • Ten Failed to make request entries follow, from 00:55:12.801 (the bridge answers 500, nanodbc ... HY000: HTTP status code: 404) to 01:04:16.206, the last logged as Failed at try 10/10. Each gap is the 60 s http_receive_timeout plus a backoff doubling up to the 10 s http_retry_max_backoff_ms cap.

That is 569 s of retrying after the query was already cancelled, against a hung check that waits 90 s for the processlist to drain. doWithRetries never consults cancellation, and sleepForMilliseconds is not interruptible, so nothing between the two observations can stop it.

Two open pull requests put CurrentThread::checkIfNotCancelled on that retry path, which is what ends this hang:

#112930 is a superset of #112144 for this failure, and its unconditional check reaches every user of the buffer, including StorageXDBC. If you would rather keep only yours, tell me and I will close #112144.

On the first bullet: #113248 is still open, so that attribution holds and I have nothing pending there.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@alexey-milovidov alexey-milovidov self-assigned this Aug 4, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 4, 2026
Merged via the queue into master with commit 83406ef Aug 4, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the wasm-target-scaffolding branch August 4, 2026 22:00
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 4, 2026
@groeneai

groeneai commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

The fix is up: #113393.

It reaps the test process groups the abort path orphans, which is defect 1 above (the
empty report). The group a force-killed worker leaves behind holds the inherited stdout,
so clickhouse-test | ts | tee never sees EOF and the job dies at its ceiling before
collecting anything; and nothing could reap it, because the PGID record was unlinked
before the kill it exists for. The apt-get lldb output was the last thing printed, not
the cause.

Defect 2, the server death itself, is not attributable from that job: no server process
was left to attach to and, per defect 1, the server log and fatal.log were never
uploaded. #113393 does not explain it. It makes the next occurrence arrive with the
artifacts to.

alexey-milovidov pushed a commit to rorylshanks/ClickHouse that referenced this pull request Aug 11, 2026
PR ClickHouse#112911 made `emcmake cmake` configure this tree and the layers up to
`clickhouse_common_io` compile to `wasm64`. Pin that state in CI so it
cannot regress: a `Build (wasm64)` job among the special builds, running
in both the PR and master workflows.

The job configures through `emcmake` (Emscripten's toolchain file supplies
`emcc`/`em++`, so no compiler is passed) and builds exactly the targets
that are known to work: `common` and `clickhouse_common_io`. The compiler
cache is disabled because `emcc` is a Python driver that sccache cannot
cache. The binary-builder image gets the Emscripten SDK pinned to 6.0.5,
the version the target was verified with, and pre-generates the wasm64
variant of the system libraries (`-sMEMORY64`, `-fwasm-exceptions` and
`-pthread` are ABI flags, see cmake/target.cmake), so CI builds do not
compile them lazily at first use.

Verified with the exact CI configure and build commands: 2539 objects
across 28 contrib libraries, base and src compile with zero warnings, and
both archives link; `llvm-readobj` confirms `Arch: wasm64`. The whole
build takes ~30 seconds of wall time on a 96-core machine, making it one
of the cheapest build jobs.

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-build Pull request with build/testing/packaging improvement pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants