From b6f30cae9a504aacb71c14aa035e2cfdadbfa17a Mon Sep 17 00:00:00 2001 From: Mattia Pitossi Date: Mon, 13 Jul 2026 13:33:23 +0200 Subject: [PATCH] rt: flush CQE in case of CQE overflow (#8277) --- tokio/src/runtime/io/driver.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tokio/src/runtime/io/driver.rs b/tokio/src/runtime/io/driver.rs index ab7c931df..5bcdecbf6 100644 --- a/tokio/src/runtime/io/driver.rs +++ b/tokio/src/runtime/io/driver.rs @@ -233,6 +233,18 @@ impl Driver { let mut guard = handle.get_uring().lock(); let ctx = &mut *guard; ctx.dispatch_completions(); + + // There might be some cases where the CQ overflows, so we need to flush + // the remaining buffered CQEs. + while ctx + .uring + .as_mut() + .is_some_and(|uring| uring.submission().cq_overflow()) + { + ctx.submit() + .expect("failed to flush io_uring completion queue overflow"); + ctx.dispatch_completions(); + } } handle.metrics.incr_ready_count_by(ready_count);