MDEV-39925: Fix error reporting in create_libaio#5192
Conversation
The io_setup function in libaio returns a negated errno value on error, but strerror expects a normal errno value.
|
|
There was a problem hiding this comment.
Code Review
This pull request modifies tpool/aio_libaio.cc to pass the negated return value of io_setup to strerror when printing a warning message. Since io_setup returns a negative error code on failure, negating it ensures strerror receives the correct positive error number. There are no review comments, and I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (int ret= io_setup(max_io, &ctx)) | ||
| { | ||
| fprintf(stderr, "Warning: io_setup(%d) returned %s. See man 2 io_setup.\n", | ||
| max_io, strerror(ret)); | ||
| max_io, strerror(-ret)); | ||
| return nullptr; | ||
| } |
There was a problem hiding this comment.
man 2 io_setup on my Debian GNU/Linux Sid system tells me that we’d better check the errno:
RETURN VALUE
On success,
io_setup()returns 0. On error, -1 is returned, anderrnois set to indicate the error.
Did you test the following?
if (io_setup(max_io, &ctx))
{
fprintf(stderr, "Warning: io_setup(%d) returned %s. See man 2 io_setup.\n",
max_io, strerror(errno));There was a problem hiding this comment.
Previously , only numeric errno was printed out, which at least would not sparkle this discussion. I think numeric value should still be printed maybe together with strerror. At least we'd know if @andreas-schwab is right. Also, not everyone in support like to read a possibly localized error. @grooverdan ?
There was a problem hiding this comment.
@dr-m as already said: man 2 io_setup notes there's a syscall difference with the libaio wrappers that we use related to this particular case of error handling. The suggested variant is rather worse:
Warning: io_setup(2048) returned Success. See man 2 io_setup.
2026-06-09 12:17:32 0 [Warning] InnoDB: native AIO failed: falling back to innodb_use_native_aio=OFF
@andreas-schwab is right and I tested:
Warning: io_setup(2048) returned Resource temporarily unavailable. See man 2 io_setup.
I think numeric value should still be printed maybe together with strerror.
Easy enough.
diff --git a/tpool/aio_libaio.cc b/tpool/aio_libaio.cc
index 013c407c205..1ca82a080a1 100644
--- a/tpool/aio_libaio.cc
+++ b/tpool/aio_libaio.cc
@@ -201,8 +201,8 @@ aio *create_libaio(thread_pool *pool, int max_io)
memset(&ctx, 0, sizeof ctx);
if (int ret= io_setup(max_io, &ctx))
{
- fprintf(stderr, "Warning: io_setup(%d) returned %s. See man 2 io_setup.\n",
- max_io, strerror(-ret));
+ fprintf(stderr, "Warning: io_setup(%d) returned %s(errno: %d). See man 2 io_setup.\n",
+ max_io, strerror(-ret), -ret);
return nullptr;
}
return new aio_libaio(ctx, pool);
To output:
Warning: io_setup(2048) returned Resource temporarily unavailable(errno: 11). See man 2 io_setup.
Leaving support folks to double check with:
$ errno 11
EAGAIN 11 Resource temporarily unavailable
Which matches the err on the man page.
Thanks @andreas-schwab. If you could:
- rebase to 10.11, git force push (to same branch name, and edit PR title to adjust target branch to 10.11)
- include MDEV at beginning of commit
- include numeric output
- a quick "I submit this under the MCA" or "I submit this under a BSD-new" PR comment.
Thanks for fixing my incorrect code in ba9e8eb.
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
- Please backport the fix to 10.11: this is a bug fix and 10.11 suffers the same issues.
- For future reference pease consider filing a jira with the description of the problem first. I did open one for you on this.
- Please sort out the CLA assistant in the pull request test section. You will need to clearly indicate the licensing on your fix.
Otherwise, the fix itself is reasonable and I see that you are already working with Marko on it. Good stuff! Please keep doing that.
|
Please read the whole manpage: |
|
https://cla-assistant.io/MariaDB/server?pullRequest=5192 doesn't work. |
then just put a comment about the licensing. |
The io_setup function in libaio returns a negated errno value on error,
but strerror expects a normal errno value.