Repository navigation
fix(io): prevent io_uring requests from hanging - #8725
Conversation
There was a problem hiding this comment.
❌ Gate recommendation: request changes.
The startup and submission-progress fixes are directionally sound, but fatal-worker shutdown must make admission and draining atomic. Every successful enqueue must either be failed by its sender or remain visible to the worker's final drain; otherwise the indefinite-pending state remains reachable.
A viable revision can serialize admission with shutdown or use a channel/ownership protocol whose close operation prevents successful late enqueue, with a deterministic concurrent-send regression.
| for request in pending.drain().map(|(_, request)| request) { | ||
| request.fail(io::Error::new(error_kind, error_message.clone())); | ||
| } | ||
| for request in request_rx.try_iter() { |
There was a problem hiding this comment.
A successful send can land after this one-shot drain. A sender that read is_alive == true may enqueue while the receiver is still open after try_iter() has observed empty; because the failed receive does not synchronize the worker's Release store with that later sender, its post-send Acquire load can still observe true. The receiver then drops the queued Arc<IoRequest>, leaving the future's copy incomplete and never woken.
Make closing admission atomic with the final drain—for example, serialize the liveness check plus send against mark-dead plus drain, or use a closeable ownership protocol where a successful send is guaranteed to be drainable. Add a bounded concurrency regression.
Bounded reproducer
With loom = "0.7.2", I ran cargo run --offline on this model of the current protocol:
use loom::sync::{
Arc,
atomic::{AtomicBool, Ordering},
mpsc,
};
use loom::thread;
fn main() {
let mut model = loom::model::Builder::new();
model.preemption_bound = Some(3);
model.check(|| {
let is_alive = Arc::new(AtomicBool::new(true));
let request_completed = Arc::new(AtomicBool::new(false));
let (request_tx, request_rx) = mpsc::channel::<()>();
let sender_is_alive = Arc::clone(&is_alive);
let sender_completed = Arc::clone(&request_completed);
let sender = thread::spawn(move || {
if !sender_is_alive.load(Ordering::Acquire) {
sender_completed.store(true, Ordering::Release);
return;
}
if request_tx.send(()).is_err() {
sender_completed.store(true, Ordering::Release);
return;
}
if !sender_is_alive.load(Ordering::Acquire) {
sender_completed.store(true, Ordering::Release);
}
});
let worker_is_alive = Arc::clone(&is_alive);
let worker_completed = Arc::clone(&request_completed);
let worker = thread::spawn(move || {
worker_is_alive.store(false, Ordering::Release);
while request_rx.try_recv().is_ok() {
worker_completed.store(true, Ordering::Release);
}
drop(request_rx);
});
sender.join().unwrap();
worker.join().unwrap();
assert!(
request_completed.load(Ordering::Acquire),
"a successful send was neither drained nor failed"
);
});
}Expected: every accepted request is completed or failed. Observed: Loom panics with Messages leaked. and reports one message, demonstrating the late accepted request.
Fixes #8787. The uring test module assumed that its process-wide worker pool always contained a usable worker. Since #8725 correctly reports worker initialization failures, resource-constrained runners reached that error during reads and failed the test process under nextest fail-fast. This change gates the io_uring-dependent cases on the shared worker pool and returns cleanly when no worker initialized. The regular `file://` control test remains active, and production io_uring error behavior is unchanged. Validation: - `LANCE_URING_THREAD_COUNT=0 cargo test -p lance-io uring::tests:: -- --test-threads=1` - `cargo test -p lance-io uring:: -- --test-threads=1` - `cargo fmt --all -- --check` - `cargo clippy --all --tests --benches -- -D warnings` <!-- lance-gatekeeper-fix:v1 agent=8ea9ef0ff8720edc27dfe19dc3c3833c generation=1 --> Co-authored-by: Gatefixer <312823363+lance-gatefixer[bot]@users.noreply.github.com>
Fixes #8723.
The io_uring request sender was published before ring initialization. If initialization failed, a request could be accepted by a channel whose worker had already exited, leaving its future pending indefinitely.
This change:
Validation:
cargo test -p lance-io uring:: -- --test-threads=1on Linux: 18 passed;cargo clippy --all --tests --benches -- -D warnings;io_uring_setupreturnedEPERM; the fixed path returns the preserved initialization error immediately.CI and nextest configuration are unchanged.