Skip to content

Commit a87bb96

Browse files
committed
MDEV-36234: Add innodb_linux_aio
This controls which linux implementation to use for innodb_use_native_aio=ON. innodb_linux_aio=auto is equivalent to innodb_linux_aio=io_uring when it is available, and falling back to innodb_linux_aio=aio when not. Debian packaging is no longer aio exclusive or uring, so for those older Debian or Ubuntu releases, its a remove_uring directive. For more recent releases, add mandatory liburing for consistent packaging. WITH_LIBAIO is now an independent option from WITH_URING. LINUX_NATIVE_AIO preprocessor constant is renamed to HAVE_LIBAIO, analogous to existing HAVE_URING. tpool::is_aio_supported(): A common feature check. is_linux_native_aio_supported(): Remove. This had originally been added in mysql/mysql-server@0da310b in 2012 to fix an issue where io_submit() on CentOS 5.5 would return EINVAL for a /tmp/#sql*.ibd file associated with CREATE TEMPORARY TABLE. But, starting with commit 2e814d4 InnoDB temporary tables will be written to innodb_temp_data_file_path. The 2012 commit said that the error could occur on "old kernels". Any GNU/Linux distribution that we currently support should be based on a newer Linux kernel; for example, Red Hat Enterprise Linux 7 was released in 2014. tpool::create_linux_aio(): Wraps the Linux implementations: create_libaio() and create_liburing(), each defined in separate compilation units (aio_linux.cc, aio_libaio.cc, aio_liburing.cc). The CMake definitions are simplified using target_sources() and target_compile_definitions(), all available since CMake 2.8.12. With this change, there is no need to include ${CMAKE_SOURCE_DIR}/tpool or add TPOOL_DEFINES flags anymore, target_link_libraries(lib tpool) does all that. This is joint work with Daniel Black and Vladislav Vaintroub.
1 parent 107d1ef commit a87bb96

29 files changed

+512
-453
lines changed

cmake/plugin.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ MACRO(MYSQL_ADD_PLUGIN)
161161
PROPERTIES COMPILE_DEFINITIONS "EMBEDDED_LIBRARY${version_string}")
162162
ENDIF()
163163
ADD_DEPENDENCIES(${target}_embedded GenError ${ARG_DEPENDS})
164+
IF(ARG_LINK_LIBRARIES)
165+
TARGET_LINK_LIBRARIES (${target}_embedded ${ARG_LINK_LIBRARIES})
166+
ENDIF()
164167
ENDIF()
165168
ENDIF()
166169

debian/autobake-deb.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ add_lsb_base_depends()
6464
sed -e 's#lsof #lsb-base (>= 3.0-10),\n lsof #' -i debian/control
6565
}
6666

67-
replace_uring_with_aio()
67+
remove_uring()
6868
{
69-
sed 's/liburing-dev/libaio-dev/g' -i debian/control
70-
sed -e '/-DIGNORE_AIO_CHECK=ON/d' \
71-
-e '/-DWITH_URING=ON/d' -i debian/rules
69+
sed -e '/liburing-dev/d' -i debian/control
70+
sed -e '/-DWITH_URING=ON/d' -i debian/rules
7271
}
7372

7473
disable_libfmt()
@@ -116,7 +115,7 @@ in
116115
# Debian
117116
"buster")
118117
disable_libfmt
119-
replace_uring_with_aio
118+
remove_uring
120119
;&
121120
"bullseye")
122121
add_lsb_base_depends
@@ -127,7 +126,7 @@ in
127126
# so no removal is necessary.
128127
if [[ ! "$architecture" =~ amd64|arm64|armel|armhf|i386|mips64el|mipsel|ppc64el|s390x ]]
129128
then
130-
replace_uring_with_aio
129+
remove_uring
131130
fi
132131
;&
133132
"trixie"|"sid")
@@ -136,8 +135,8 @@ in
136135
;;
137136
# Ubuntu
138137
"focal")
139-
replace_uring_with_aio
140138
disable_libfmt
139+
remove_uring
141140
;&
142141
"jammy"|"kinetic")
143142
add_lsb_base_depends

debian/rules

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ endif
8787
# quality standards in Debian. Also building it requires an extra 4 GB of disk
8888
# space which makes native Debian builds fail as the total disk space needed
8989
# for MariaDB becomes over 10 GB. Only build CS via autobake-deb.sh.
90-
#
91-
# Note: Don't use '-DWITH_URING=ON' as some Buildbot builders are missing it
92-
# and would fail permanently.
9390
PATH=$${MYSQL_BUILD_PATH:-"/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin"} \
9491
dh_auto_configure --builddirectory=$(BUILDDIR) -- \
9592
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
@@ -103,6 +100,8 @@ endif
103100
-DPLUGIN_AWS_KEY_MANAGEMENT=NO \
104101
-DPLUGIN_COLUMNSTORE=NO \
105102
-DIGNORE_AIO_CHECK=ON \
103+
-DWITH_URING=ON \
104+
-DWITH_LIBAIO=ON \
106105
-DDEB=$(DEB_VENDOR)
107106

108107
# This is needed, otherwise 'make test' will run before binaries have been built

extra/mariabackup/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ MYSQL_ADD_EXECUTABLE(mbstream
107107
TARGET_LINK_LIBRARIES(mbstream
108108
mysys
109109
)
110+
111+
TARGET_INCLUDE_DIRECTORIES(mbstream PRIVATE ${PROJECT_SOURCE_DIR}/tpool)
110112
ADD_DEPENDENCIES(mbstream GenError)
111113

112114
IF(MSVC)

extra/mariabackup/xtrabackup.cc

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ extern const char *innodb_checksum_algorithm_names[];
378378
extern TYPELIB innodb_checksum_algorithm_typelib;
379379
extern const char *innodb_flush_method_names[];
380380
extern TYPELIB innodb_flush_method_typelib;
381+
#ifdef __linux__
382+
extern const char *innodb_linux_aio_names[];
383+
extern TYPELIB innodb_linux_aio_typelib;
384+
#endif
381385

382386
static const char *binlog_info_values[] = {"off", "lockless", "on", "auto",
383387
NullS};
@@ -1334,6 +1338,9 @@ enum options_xtrabackup
13341338
OPT_INNODB_READ_IO_THREADS,
13351339
OPT_INNODB_WRITE_IO_THREADS,
13361340
OPT_INNODB_USE_NATIVE_AIO,
1341+
#ifdef __linux__
1342+
OPT_INNODB_LINUX_AIO,
1343+
#endif
13371344
OPT_INNODB_PAGE_SIZE,
13381345
OPT_INNODB_BUFFER_POOL_FILENAME,
13391346
OPT_INNODB_LOCK_WAIT_TIMEOUT,
@@ -1934,6 +1941,14 @@ struct my_option xb_server_options[] =
19341941
(G_PTR*) &srv_use_native_aio,
19351942
(G_PTR*) &srv_use_native_aio, 0, GET_BOOL, NO_ARG,
19361943
TRUE, 0, 0, 0, 0, 0},
1944+
#ifdef __linux__
1945+
{"innodb_linux_aio", OPT_INNODB_LINUX_AIO,
1946+
"Which linux AIO implementation to use, auto (io_uring, failing to aio) or explicit",
1947+
(G_PTR*) &srv_linux_aio_method,
1948+
(G_PTR*) &srv_linux_aio_method,
1949+
&innodb_linux_aio_typelib, GET_ENUM, REQUIRED_ARG,
1950+
SRV_LINUX_AIO_AUTO, 0, 0, 0, 0, 0},
1951+
#endif
19371952
{"innodb_page_size", OPT_INNODB_PAGE_SIZE,
19381953
"The universal page size of the database.",
19391954
(G_PTR*) &innobase_page_size, (G_PTR*) &innobase_page_size, 0,
@@ -2529,26 +2544,7 @@ static bool innodb_init_param()
25292544

25302545
ut_ad(DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number);
25312546

2532-
#ifdef _WIN32
2533-
srv_use_native_aio = TRUE;
2534-
2535-
#elif defined(LINUX_NATIVE_AIO)
2536-
2537-
if (srv_use_native_aio) {
2538-
msg("InnoDB: Using Linux native AIO");
2539-
}
2540-
#elif defined(HAVE_URING)
2541-
2542-
if (srv_use_native_aio) {
2543-
msg("InnoDB: Using liburing");
2544-
}
2545-
#else
2546-
/* Currently native AIO is supported only on windows and linux
2547-
and that also when the support is compiled in. In all other
2548-
cases, we ignore the setting of innodb_use_native_aio. */
2549-
srv_use_native_aio = FALSE;
2550-
2551-
#endif
2547+
srv_use_native_aio= tpool::supports_native_aio();
25522548

25532549
/* Assign the default value to srv_undo_dir if it's not specified, as
25542550
my_getopt does not support default values for string options. We also
@@ -2583,9 +2579,6 @@ static bool innodb_init_param()
25832579
}
25842580
}
25852581

2586-
#ifdef _WIN32
2587-
srv_use_native_aio = TRUE;
2588-
#endif
25892582
return false;
25902583

25912584
error:
@@ -5473,7 +5466,6 @@ static bool xtrabackup_backup_func()
54735466
xb_fil_io_init();
54745467

54755468
if (os_aio_init()) {
5476-
msg("Error: cannot initialize AIO subsystem");
54775469
goto fail;
54785470
}
54795471

libmysqld/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ INCLUDE_DIRECTORIES(
2121
${CMAKE_SOURCE_DIR}/include
2222
${CMAKE_SOURCE_DIR}/libmysqld
2323
${CMAKE_SOURCE_DIR}/sql
24-
${CMAKE_SOURCE_DIR}/tpool
2524
${CMAKE_BINARY_DIR}/sql
2625
${PCRE_INCLUDE_DIRS}
2726
${LIBFMT_INCLUDE_DIR}

mysql-test/mariadb-test-run.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4548,7 +4548,7 @@ ($$)
45484548
qr|InnoDB: io_setup\(\) attempt|,
45494549
qr|InnoDB: io_setup\(\) failed with EAGAIN|,
45504550
qr|io_uring_queue_init\(\) failed with|,
4551-
qr|InnoDB: liburing disabled|,
4551+
qr|InnoDB: io_uring failed: falling back to libaio|,
45524552
qr/InnoDB: Failed to set O_DIRECT on file/,
45534553
qr|setrlimit could not change the size of core files to 'infinity';|,
45544554
qr|failed to retrieve the MAC address|,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
select @@global.innodb_linux_aio;
2+
@@global.innodb_linux_aio
3+
auto
4+
select @@session.innodb_linux_aio;
5+
ERROR HY000: Variable 'innodb_linux_aio' is a GLOBAL variable
6+
show global variables like 'innodb_linux_aio';
7+
Variable_name Value
8+
innodb_linux_aio auto
9+
show session variables like 'innodb_linux_aio';
10+
Variable_name Value
11+
innodb_linux_aio auto
12+
select * from information_schema.global_variables where variable_name='innodb_linux_aio';
13+
VARIABLE_NAME VARIABLE_VALUE
14+
INNODB_LINUX_AIO auto
15+
select * from information_schema.session_variables where variable_name='innodb_linux_aio';
16+
VARIABLE_NAME VARIABLE_VALUE
17+
INNODB_LINUX_AIO auto
18+
set global innodb_linux_aio='auto';
19+
ERROR HY000: Variable 'innodb_linux_aio' is a read only variable
20+
set session innodb_linux_aio='aio';
21+
ERROR HY000: Variable 'innodb_linux_aio' is a read only variable

mysql-test/suite/sys_vars/r/sysvars_innodb.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ variable_name not in (
55
'innodb_evict_tables_on_commit_debug', # one may want to override this
66
'innodb_use_native_aio', # default value depends on OS
77
'innodb_log_file_buffering', # only available on Linux and Windows
8+
'innodb_linux_aio', # existence depends on OS
89
'innodb_buffer_pool_load_pages_abort') # debug build only, and is only for testing
910
order by variable_name;
1011
VARIABLE_NAME INNODB_ADAPTIVE_FLUSHING
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--source include/have_innodb.inc
2+
--source include/linux.inc
3+
# enum readonly
4+
5+
#
6+
# show values;
7+
#
8+
select @@global.innodb_linux_aio;
9+
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
10+
select @@session.innodb_linux_aio;
11+
show global variables like 'innodb_linux_aio';
12+
show session variables like 'innodb_linux_aio';
13+
select * from information_schema.global_variables where variable_name='innodb_linux_aio';
14+
select * from information_schema.session_variables where variable_name='innodb_linux_aio';
15+
16+
#
17+
# show that it's read-only
18+
#
19+
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
20+
set global innodb_linux_aio='auto';
21+
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
22+
set session innodb_linux_aio='aio';
23+

0 commit comments

Comments
 (0)