Skip to content

Commit 92738f3

Browse files
archang19facebook-github-bot
authored andcommitted
Log errno and thread ID on CreateIOUring failure (facebook#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. Differential Revision: D98526792
1 parent 47de3a3 commit 92738f3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

env/io_posix.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// found in the LICENSE file. See the AUTHORS file for names of contributors.
99
#pragma once
1010
#include <errno.h>
11+
#include <pthread.h>
12+
#include <stdio.h>
13+
#include <string.h>
1114
#if defined(ROCKSDB_IOURING_PRESENT)
1215
#include <liburing.h>
1316
#include <sys/uio.h>
@@ -341,6 +344,8 @@ inline struct io_uring* CreateIOUring() {
341344
flags |= IORING_SETUP_DEFER_TASKRUN;
342345
int ret = io_uring_queue_init(kIoUringDepth, new_io_uring, flags);
343346
if (ret) {
347+
fprintf(stderr, "CreateIOUring failed: %s (errno=%d), thread=%lu\n",
348+
strerror(-ret), -ret, static_cast<unsigned long>(pthread_self()));
344349
delete new_io_uring;
345350
new_io_uring = nullptr;
346351
}

0 commit comments

Comments
 (0)