Skip to content

Commit 239b06c

Browse files
archang19facebook-github-bot
authored andcommitted
Retry on some io_uring_wait_cqe error codes (facebook#13890)
Summary: RocksDB currently aborts whenever `io_uring_wait_cqe` returns an error code. It also does not log what error code was returned. While experimenting with `IO_URING`, my application crashed because of this. I asked the Linux Kernel user group the best way to handle unsuccessful `io_uring_wait_cqe`. It was recommended to retry on `EINTR`, `EAGAIN`, and `ETIME`. `ETIME` only happens when waiting with a timeout, so I am not handling it. I also write to `stderr` so that we have some debugging information if we abort. Pull Request resolved: facebook#13890 Test Plan: Unfortunately this is hard to cover through unit/stress tests. We have to see what sort of errors get encountered in production. Reviewed By: anand1976 Differential Revision: D80639955 Pulled By: archang19 fbshipit-source-id: e3a230bd37552ec0f36be34e6a4e53cfd2a254f1
1 parent b9957c9 commit 239b06c

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

env/fs_posix.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,8 +1107,10 @@ class PosixFileSystem : public FileSystem {
11071107
struct io_uring_cqe* cqe = nullptr;
11081108
ssize_t ret = io_uring_wait_cqe(iu, &cqe);
11091109
if (ret) {
1110-
// abort as it shouldn't be in indeterminate state and there is no
1111-
// good way currently to handle this error.
1110+
fprintf(stderr, "Poll: io_uring_wait_cqe failed: %ld", (long)ret);
1111+
if (ret == -EINTR || ret == -EAGAIN) {
1112+
continue; // Retry
1113+
}
11121114
abort();
11131115
}
11141116

@@ -1210,8 +1212,10 @@ class PosixFileSystem : public FileSystem {
12101212
struct io_uring_cqe* cqe = nullptr;
12111213
ssize_t ret = io_uring_wait_cqe(iu, &cqe);
12121214
if (ret) {
1213-
// abort as it shouldn't be in indeterminate state and there is no
1214-
// good way currently to handle this error.
1215+
fprintf(stderr, "AbortIO: io_uring_wait_cqe failed: %ld", (long)ret);
1216+
if (ret == -EINTR || ret == -EAGAIN) {
1217+
continue; // Retry
1218+
}
12151219
abort();
12161220
}
12171221
assert(cqe != nullptr);

0 commit comments

Comments
 (0)