Repository navigation
fix: block SIGPIPE on the ADBC and pyo3 runtime threads - #510
Draft
vuanhphung wants to merge 1 commit into
Draft
vuanhphung wants to merge 1 commit into
vuanhphung wants to merge 1 commit into
Conversation
Export the kernel's block_sigpipe_on_current_thread as a #[doc(hidden)] crate-root item and hook it with on_thread_start on the ADBC driver-owned runtime and the pyo3 per-session runtime, workers and blocking pools. Caller-injected ADBC runtimes are left alone. Linux tests check that a worker and a spawn_blocking thread of each runtime block SIGPIPE. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
vuanhphung
changed the base branch from
main
to
fix/block-sigpipe-runtime-threads
November 27, 2026 02:20
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #509, which blocks SIGPIPE on the kernel's C-ABI and telemetry runtime threads. Two other runtimes run kernel socket I/O on threads they own, and neither was hooked:
RuntimeHandle::create). When a Go program loads the driver through a cgo driver manager, a SIGPIPE raised on one of its workers kills the process.SIG_DFL, a common CLI idiom, is killed instead of gettingEPIPE.This PR re-exports the kernel's
block_sigpipe_on_current_threadfrom the crate root as#[doc(hidden)]. That is the smallest surface the sibling crates can use through their existing path dependency. Both runtimes now pass it toon_thread_start, so it covers workers and blocking-pool threads. The pyo3 builder moves fromSession.__new__intoKernelRuntime::buildso a test can check the real runtime; it is otherwise unchanged. Caller-injected ADBC runtimes and napi (Node ignores SIGPIPE) are left alone.How exposed each runtime is today depends on its TLS backend. pyo3 builds with
tls-rustls, which writes TLS records withwritev, so any write after a peer reset raises SIGPIPE. ADBC uses the defaulttls-native:tokio-native-tlshas onlypoll_write(tokio-native-tls/src/lib.rs:149,205@02c1aeb), so on Linux its TLS writes end in std'ssend(MSG_NOSIGNAL). ADBC is therefore exposed only through plain-HTTPwritevtoday; the hook matches the C-ABI runtime and covers any later rustls build.Depends on #509 and targets its branch, so the diff shows only this change. It will be retargeted to
mainafter #509 merges.Cross-driver state
tls-nativebuilds already useMSG_NOSIGNAL(see above)SIG_DFL→ Fixed (this PR)SIG_IGNby default (Modules/signalmodule.c:1913@v3.13.0); databricks-sql-python has no SIGPIPE handlingSIG_IGN(src/node.cc:544@v22.11.0)No other Databricks driver blocks SIGPIPE itself; this follows #509's thread-scoped mask.
Testing
owned_runtime_threads_block_sigpipe(adbc) andsession_runtime_threads_block_sigpipe(pyo3), build the real runtime (RuntimeHandle::create,KernelRuntime::build). Each runs a task on a worker and on aspawn_blockingthread and checks SIGPIPE's bit inSigBlk, after first asserting that the test thread doesn't block it. fix: block SIGPIPE on kernel runtime threads #509's helper iscfg(test)in the kernel crate, so each crate carries a ten-line copy. fix: block SIGPIPE on kernel runtime threads #509's end-to-endSIG_DFLtest isn't duplicated.main, so CI ran on 3d8ed34 while this PR briefly targetedmain. Every check passed, exceptmacOS dSYM, which is cancelled at its timeout on every recentmainpush (e.g. run 45768020222). Highlights:ADBC native + C ABI(toolchain 1.89): clippy-D warningsand 99 tests pass, includingowned_runtime_threads_block_sigpipe; the dlopen smoke test passes.PyO3 build + testjobs passsession_runtime_threads_block_sigpipe. Their no-network pytest tests build a realSessionagainst a local HTTP server, which exercises the moved builder.v0 E2E surfaceandv0 TLS (mitmproxy)jobs all pass.main(21 passed, 37 skipped in both; e.g. main run 45768020141). The label-gated ADBC live suite wasn't run.pthread_sigmaskcall per runtime thread start and nothing on the request path.Additional notes
block_onstill run on the caller's thread, which keeps the host's mask. Hyper's connection tasks, which do the writes on established connections, run on the hooked workers.pyo3_logruns Python logging handlers on the thread that emits the record. In an app that restoredSIG_DFL, a handler on a session worker that writes to a closed pipe now getsBrokenPipeErrorinstead of killing the process, the same effect fix: block SIGPIPE on kernel runtime threads #509 noted for C-ABI log callbacks. Apps that keep Python's defaultSIG_IGNsee no change.This pull request and its description were written by Isaac.