Skip to content

Commit

Permalink
MDEV-26674: Set innodb_use_native_aio=OFF when using io_uring on a po…
Browse files Browse the repository at this point in the history
…tentially affected kernel

We have observed hangs of the io_uring subsystem when using a
Linux kernel newer than 5.10. Also 5.15-rc6 is affected by this.

The exact cause of the hangs has not been diagnosed yet.
As a safety measure, we will disable innodb_use_native_aio by default
when the server has been configured with io_uring and the kernel
version is between 5.11 and 5.15.

If the start-up parameter innodb_use_native_aio=ON is set, then
we will issue a warning to the server error log.
  • Loading branch information
dr-m committed Oct 25, 2021
1 parent 1f02280 commit 1193a79
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ void close_thread_tables(THD* thd);
#include "wsrep_sst.h"
#endif /* WITH_WSREP */

#ifdef HAVE_URING
/** The Linux kernel version if io_uring() is considered unsafe */
static const char *io_uring_may_be_unsafe;
#endif

#define INSIDE_HA_INNOBASE_CC

#define EQ_CURRENT_THD(thd) ((thd) == current_thd)
Expand Down Expand Up @@ -4046,6 +4051,14 @@ static int innodb_init_params()
cases, we ignore the setting of innodb_use_native_aio. */
srv_use_native_aio = FALSE;
#endif
#ifdef HAVE_URING
if (srv_use_native_aio && io_uring_may_be_unsafe) {
sql_print_warning("innodb_use_native_aio may cause "
"hangs with this kernel %s; see "
"https://jira.mariadb.org/browse/MDEV-26674",
io_uring_may_be_unsafe);
}
#endif

#ifndef _WIN32
ut_ad(srv_file_flush_method <= SRV_O_DIRECT_NO_FSYNC);
Expand Down Expand Up @@ -19393,10 +19406,29 @@ static MYSQL_SYSVAR_STR(version, innodb_version_str,
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
"InnoDB version", NULL, NULL, INNODB_VERSION_STR);

#ifdef HAVE_URING
# include <sys/utsname.h>
static utsname uname_for_io_uring;
#endif

static bool innodb_use_native_aio_default()
{
#ifdef HAVE_URING
utsname &u= uname_for_io_uring;
if (!uname(&u) && u.release[0] == '5' && u.release[1] == '.' &&
u.release[2] == '1' && u.release[3] > '0' && u.release[3] < '6')
{
io_uring_may_be_unsafe= u.release;
return false; /* working around io_uring hangs (MDEV-26674) */
}
#endif
return true;
}

static MYSQL_SYSVAR_BOOL(use_native_aio, srv_use_native_aio,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"Use native AIO if supported on this platform.",
NULL, NULL, TRUE);
NULL, NULL, innodb_use_native_aio_default());

#ifdef HAVE_LIBNUMA
static MYSQL_SYSVAR_BOOL(numa_interleave, srv_numa_interleave,
Expand Down

0 comments on commit 1193a79

Please sign in to comment.