From b2ccf9ee3c55a9bff7d22c2851b0847dd7ba55af Mon Sep 17 00:00:00 2001 From: Andrew Chang Date: Sat, 28 Mar 2026 12:25:19 -0700 Subject: [PATCH] Log errno and thread ID on CreateIOUring failure (#14520) Summary: CreateIOUring() silently returns nullptr on failure, discarding the errno from io_uring_queue_init. This makes it impossible to diagnose why io_uring initialization fails on specific threads (e.g. ENOMEM from memlock limits, EINVAL from unsupported flags, EMFILE from fd exhaustion). Add a fprintf(stderr, ...) that logs strerror, errno, and pthread thread ID when io_uring_queue_init fails, so failures are diagnosable from logs without needing to reproduce. Reviewed By: xingbowang Differential Revision: D98526792 --- env/io_posix.cc | 1 - env/io_posix.h | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/env/io_posix.cc b/env/io_posix.cc index d28d0da99b73..8380491a0215 100644 --- a/env/io_posix.cc +++ b/env/io_posix.cc @@ -1096,7 +1096,6 @@ IOStatus PosixRandomAccessFile::ReadAsync( // Init failed, platform doesn't support io_uring. if (iu == nullptr) { - fprintf(stderr, "failed to init io_uring\n"); return IOStatus::NotSupported("ReadAsync: failed to init io_uring"); } diff --git a/env/io_posix.h b/env/io_posix.h index b660466ea69c..7fcc4e64bd5f 100644 --- a/env/io_posix.h +++ b/env/io_posix.h @@ -10,8 +10,13 @@ #include #if defined(ROCKSDB_IOURING_PRESENT) #include +#include #include +#include + +#include "util/string_util.h" + // Compatibility defines for io_uring flags that may not be present in older // kernel headers. These values are fixed and won't change, so it's safe to // define them even if the running kernel doesn't support them. @@ -341,6 +346,9 @@ inline struct io_uring* CreateIOUring() { flags |= IORING_SETUP_DEFER_TASKRUN; int ret = io_uring_queue_init(kIoUringDepth, new_io_uring, flags); if (ret) { + fprintf(stderr, "CreateIOUring failed: %s (errno=%d), thread=%lu\n", + errnoStr(-ret).c_str(), -ret, + static_cast(pthread_self())); delete new_io_uring; new_io_uring = nullptr; }