Skip to content

Bump delta-kernel-rs to fix a block_on hang when no thread can be spawned - #130544

Merged
PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:bump-delta-kernel-block-on-handoff
Nov 12, 2026
Merged

PedroTadim merged 2 commits into
ClickHouse:masterfrom
groeneai:bump-delta-kernel-block-on-handoff

Conversation

@groeneai

@groeneai groeneai commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #128033
Related: ClickHouse/delta-kernel-rs#19
Related: delta-io/delta-kernel-rs#3202

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixed DeltaLake queries hanging forever, without reacting to KILL QUERY, when delta-kernel could not create the thread that hands a result back (for example at a container PID limit).

Description

On 26.3.12.3, a DeltaLake query hangs forever and ignores KILL QUERY when the server cannot create a new thread: in #128033 a CREATE TABLE ... ENGINE = DeltaLake run by DDLWorker blocked for 26 hours at a Kubernetes PID limit and stalled the distributed DDL queue. Master and 26.8 to 26.10 pin the same kernel code.

Cause: delta-kernel's block_on handed every result back through tokio::task::spawn_blocking. When no thread can be created, tokio panics after queueing the closure that owns the result sender, so the sender is never dropped and the caller's recv() waits forever. Every synchronous kernel call goes through block_on.

Change: contrib/delta-kernel-rs moves from 88ff5a94 to 86762ee5, the merge commit of ClickHouse/delta-kernel-rs#19 (a cherry-pick of delta-io/delta-kernel-rs#3202), which sends the result directly from the async task. It touches only kernel/src/engine/default/executor.rs, with no Cargo manifest or lock change. The fork branch tip carries unrelated changes, so the pin is the fix commit, not the tip.

Validation: a standalone kernel program that lowers RLIMIT_NPROC before calling block_on hangs on 88ff5a94 (panic OS can't spawn worker thread, caller blocked in futex_wait) and returns the result on 86762ee5, in 6 of 6 runs each. The server builds with the new pin, and 59 local DeltaLake stateless tests pass. No ClickHouse test is added: running a server out of threads at exactly this point is not deterministic in a functional test.

#130062 moves the pointer to c694ca3e, which already contains this commit.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/130544]

Version info

  • Merged into: 26.11.1.2124-master (included in 26.11 and later)

…wned

delta-kernel's `block_on` handed the task result back through
`tokio::task::spawn_blocking`. When the process could not create a thread, that
call panicked after queueing the closure that owns the result sender, so the
sender was never dropped and the caller's `recv()` waited forever (the query
ignored KILL QUERY). The fix sends the result directly from the async task.

The new pin is the merge commit of ClickHouse/delta-kernel-rs#19, a cherry-pick
of delta-io/delta-kernel-rs#3202 onto `ClickHouse/v0.23.0`. It changes only
`kernel/src/engine/default/executor.rs`; no Cargo manifest or lock change.

Closes ClickHouse#128033

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (0 blocker, 0 major).

# Sev Finding Verdict Evidence / action
1 💡 No ClickHouse test, so new_tests_check needs ci-skip-new-tests-check AGREE no code change; a functional test cannot exhaust threads at exactly the handoff, the fork carries the #3202 executor test

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-8:20261110-160200

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, at the kernel layer: a program that creates a TokioBackgroundExecutor, lowers its own RLIMIT_NPROC (prlimit --nproc=1:1, confirmed by a failing probe spawn), then calls block_on(async { 42 }).
b Root cause explained? The block_on handoff called tokio::task::spawn_blocking; with no thread available tokio queues the closure that owns the result sender and panics, the sender is never dropped, and the caller's recv() blocks forever. All synchronous kernel calls use block_on, so the query hangs and ignores KILL QUERY.
c Fix matches root cause? Yes. The kernel now sends the result directly from the async task (delta-io/delta-kernel-rs#3202, cherry-picked as ClickHouse/delta-kernel-rs#19); the PR moves the pointer to that merge commit. No timeout or guard on the ClickHouse side.
d Test intent preserved / new tests added? No ClickHouse test: exhausting the thread limit at exactly the handoff is not deterministic in a functional test (a clickhouse local attempt fails earlier, at engine creation, with Code: 742 on both binaries). 59 local DeltaLake stateless tests pass, and 6 of them 50 times each (300/300).
e Both directions demonstrated? Yes, 6 runs each: 88ff5a94 panics OS can't spawn worker thread and the caller stays blocked in futex_wait (killed after 15 s); 86762ee5 prints RESULT 42 and exits 0.
f Fix is general across code paths? The same commit fixes both TokioBackgroundExecutor::block_on and TokioMultiThreadExecutor::block_on. The executors' own spawn_blocking has no caller in kernel/src or ffi/src. A failed thread spawn at engine creation is caught at the FFI boundary and becomes an exception.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A: the change is in the kernel executor and does not depend on schema, format, storage or query kind; snapshot load, scan, CDF and writes all share it.
h Backward compatible? (maintainer-approved exception only) Yes. No setting, format or FFI change; ffi/, Cargo.toml and Cargo.lock are unchanged.
i Invariants and contracts preserved? block_on still returns the task output exactly once. The channel is an unbounded std::sync::mpsc channel, so send never blocks the runtime thread; a dropped receiver is still ignored, and a panicking task still drops the sender so recv() fails as before.

Session id: cron:clickhouse-impl-slot-41:20261110-145400

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @SmitaRKulkarni @Algunenano, could you review this and add the can be tested label so CI runs, plus ci-skip-new-tests-check (no ClickHouse test, see the Description)? It moves contrib/delta-kernel-rs to the merge commit of ClickHouse/delta-kernel-rs#19, where block_on sends the result directly from the async task instead of through spawn_blocking, so a failed thread spawn no longer leaves the caller waiting forever.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Nov 10, 2026
@PedroTadim PedroTadim self-assigned this Nov 10, 2026
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Nov 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6bb9871]

Summary: ❌

job_name test_name status info comment
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/new_tests_check.py FAIL IGNORED

AI Review

Summary

PR #130544 updates contrib/delta-kernel-rs from 3ae30627 to 4cf98946, removing the blocking-pool result handoff from both implementations of block_on. This fixes the reported DeltaLake hang when the handoff cannot obtain a thread. No actionable findings. The included kernel regression test and documented before/after reproduction support the fix; no local tests were run during this review.

ClickHouse-Specific Rule Notes

💡 The Finish Workflow report reports only the missing ClickHouse test. The PR documents why deterministic server-level coverage is impractical and requests the ci-skip-new-tests-check label.

Final Verdict

✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default submodule changed At least one submodule changed in this PR. comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. labels Nov 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 6bb98710c with master 1598acaa8 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.66, programs/clickhouse-keeper ×0.73 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 5.6 s 13.4 s +9.7 s (+266%)
programs/clickhouse _ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… 3.3 s 7.5 s +5.3 s (+245%)
Compile time of recompiled translation units

6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 09e9747

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Finish Workflow / Post Hooks (new_tests_check.py: No new tests have been added) Bug Fix PR without a ClickHouse test: no functional test can make the thread spawn fail at exactly the block_on handoff PR-caused by design and owned by this PR (#130544): the resolution is the ci-skip-new-tests-check label
Performance Comparison (arm_release, master_head, 4/6) / vectorize_aggregation_combinators #4 flaky: the same slowdown on 10 other heads since 2026-11-07, including master; this diff only changes the delta-kernel executor #129327 (external, open)

Session id: cron:clickhouse-maint-slot-15:20261110-204300

Resolve the contrib/delta-kernel-rs submodule conflict by bumping to a commit
that carries both master's 'ffi: pass the target platform to cbindgen' change
and the block_on handoff deadlock fix (ClickHouse#3202).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@PedroTadim
PedroTadim enabled auto-merge November 12, 2026 10:36
@PedroTadim
PedroTadim added this pull request to the merge queue Nov 12, 2026
thevar1able added a commit to groeneai/ClickHouse that referenced this pull request Nov 12, 2026
The previous pin `c915e4c7` was the head of the fork PR, not the branch
tip `d10c6605` (its merge commit). The tip also carries the `block_on`
handoff fix from ClickHouse#130544.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged via the queue into ClickHouse:master with commit b083ddd Nov 12, 2026
399 of 402 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 12, 2026
thevar1able added a commit to groeneai/ClickHouse that referenced this pull request Nov 12, 2026
Resolve the `contrib/delta-kernel-rs` conflict with
ClickHouse#130544 by keeping the tip of
`ClickHouse/v0.23.0` (`d10c6605`), which already contains the `block_on`
handoff fix and the cbindgen target-platform change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xenx96

xenx96 commented Nov 17, 2026

Copy link
Copy Markdown

@PedroTadim could this get pr-must-backport (at least 26.3 and 26.8)?

#128033 was hit on 26.3.12.3, and the 26.3, 26.8, 26.9 and 26.10 branches still pin 3ae30627, whose kernel/src/engine/default/executor.rs hands the result back through spawn_blocking. That is the commit this PR moved master from, so the backport should be the same submodule move to 4cf98946; between the two commits only executor.rs changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. manual approve Manual approve required to run CI pr-bugfix Pull request with bugfix, not backported by default 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.

DeltaLake: delta-kernel block_on waits forever when its result-handoff thread cannot be spawned (fixed upstream in delta-kernel-rs#3202)

4 participants