Skip to content

Commit 1e03323

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. 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. This is joint work with Daniel Black and Vladislav Vaintroub.
1 parent 84dd243 commit 1e03323

23 files changed

+290
-253
lines changed

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/xtrabackup.cc

Lines changed: 21 additions & 12 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};
@@ -1325,6 +1329,9 @@ enum options_xtrabackup
13251329
OPT_INNODB_READ_IO_THREADS,
13261330
OPT_INNODB_WRITE_IO_THREADS,
13271331
OPT_INNODB_USE_NATIVE_AIO,
1332+
#ifdef __linux__
1333+
OPT_INNODB_LINUX_AIO,
1334+
#endif
13281335
OPT_INNODB_PAGE_SIZE,
13291336
OPT_INNODB_BUFFER_POOL_FILENAME,
13301337
OPT_INNODB_LOCK_WAIT_TIMEOUT,
@@ -1925,6 +1932,14 @@ struct my_option xb_server_options[] =
19251932
(G_PTR*) &srv_use_native_aio,
19261933
(G_PTR*) &srv_use_native_aio, 0, GET_BOOL, NO_ARG,
19271934
TRUE, 0, 0, 0, 0, 0},
1935+
#ifdef __linux__
1936+
{"innodb_linux_aio", OPT_INNODB_LINUX_AIO,
1937+
"Which linux AIO implementation to use, auto (io_uring, failing to aio) or explicit",
1938+
(G_PTR*) &srv_linux_aio_method,
1939+
(G_PTR*) &srv_linux_aio_method,
1940+
&innodb_linux_aio_typelib, GET_ENUM, REQUIRED_ARG,
1941+
SRV_LINUX_AIO_AUTO, 0, 0, 0, 0, 0},
1942+
#endif
19281943
{"innodb_page_size", OPT_INNODB_PAGE_SIZE,
19291944
"The universal page size of the database.",
19301945
(G_PTR*) &innobase_page_size, (G_PTR*) &innobase_page_size, 0,
@@ -2520,19 +2535,8 @@ static bool innodb_init_param()
25202535

25212536
ut_ad(DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number);
25222537

2523-
#ifdef _WIN32
2538+
#if defined(_WIN32) || defined(LINUX_NATIVE_AIO) || defined(HAVE_URING)
25242539
srv_use_native_aio = TRUE;
2525-
2526-
#elif defined(LINUX_NATIVE_AIO)
2527-
2528-
if (srv_use_native_aio) {
2529-
msg("InnoDB: Using Linux native AIO");
2530-
}
2531-
#elif defined(HAVE_URING)
2532-
2533-
if (srv_use_native_aio) {
2534-
msg("InnoDB: Using liburing");
2535-
}
25362540
#else
25372541
/* Currently native AIO is supported only on windows and linux
25382542
and that also when the support is compiled in. In all other
@@ -5467,6 +5471,11 @@ static bool xtrabackup_backup_func()
54675471
msg("Error: cannot initialize AIO subsystem");
54685472
goto fail;
54695473
}
5474+
#ifdef __linux__
5475+
if (srv_use_native_aio) {
5476+
msg("InnoDB: Using %s", srv_thread_pool->get_implementation());
5477+
}
5478+
#endif
54705479

54715480
log_sys.create();
54725481

include/my_time.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ static inline longlong sec_part_unshift(longlong second_part, uint digits)
230230
/* Date/time rounding and truncation functions */
231231
static inline long my_time_fraction_remainder(long nr, uint decimals)
232232
{
233-
DBUG_ASSERT(decimals <= TIME_SECOND_PART_DIGITS);
234233
return nr % (long) log_10_int[TIME_SECOND_PART_DIGITS - decimals];
235234
}
236235
static inline void my_datetime_trunc(MYSQL_TIME *ltime, uint decimals)

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+

mysql-test/suite/sys_vars/t/sysvars_innodb.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ select VARIABLE_NAME, SESSION_VALUE, DEFAULT_VALUE, VARIABLE_SCOPE, VARIABLE_TYP
1616
'innodb_evict_tables_on_commit_debug', # one may want to override this
1717
'innodb_use_native_aio', # default value depends on OS
1818
'innodb_log_file_buffering', # only available on Linux and Windows
19+
'innodb_linux_aio', # existence depends on OS
1920
'innodb_buffer_pool_load_pages_abort') # debug build only, and is only for testing
2021
order by variable_name;

storage/innobase/handler/ha_innodb.cc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,25 @@ static TYPELIB innodb_stats_method_typelib = {
315315
NULL
316316
};
317317

318+
/** Possible values for system variable "innodb_linux_aio" */
319+
#ifdef __linux__
320+
const char* innodb_linux_aio_names[] = {
321+
"auto", /* SRV_LINUX_AIO_AUTO */
322+
"io_uring", /* SRV_LINUX_AIO_IO_URING */
323+
"aio", /* SRV_LINUX_AIO_LIBAIO */
324+
NullS
325+
};
326+
327+
/** Used to define an enumerate type of the system variable
328+
innodb_linux_aio. Used by mariadb-backup too. */
329+
TYPELIB innodb_linux_aio_typelib = {
330+
array_elements(innodb_linux_aio_names) - 1,
331+
"innodb_linux_aio_typelib",
332+
innodb_linux_aio_names,
333+
NULL
334+
};
335+
#endif
336+
318337
/** Possible values of the parameter innodb_checksum_algorithm */
319338
const char* innodb_checksum_algorithm_names[] = {
320339
"crc32",
@@ -19659,6 +19678,15 @@ static MYSQL_SYSVAR_BOOL(use_native_aio, srv_use_native_aio,
1965919678
"Use native AIO if supported on this platform.",
1966019679
NULL, NULL, TRUE);
1966119680

19681+
#ifdef __linux__
19682+
static MYSQL_SYSVAR_ENUM(linux_aio, srv_linux_aio_method,
19683+
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
19684+
"Specifies which Linux AIO implementation should be used."
19685+
" Possible value are \"auto\" (default) to select io_uring"
19686+
" and fallback to aio, or explicit \"io_uring\" or \"aio\"",
19687+
nullptr, nullptr, SRV_LINUX_AIO_AUTO, &innodb_linux_aio_typelib);
19688+
#endif
19689+
1966219690
#ifdef HAVE_LIBNUMA
1966319691
static MYSQL_SYSVAR_BOOL(numa_interleave, srv_numa_interleave,
1966419692
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
@@ -20054,6 +20082,9 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
2005420082
MYSQL_SYSVAR(tmpdir),
2005520083
MYSQL_SYSVAR(autoinc_lock_mode),
2005620084
MYSQL_SYSVAR(use_native_aio),
20085+
#ifdef __linux__
20086+
MYSQL_SYSVAR(linux_aio),
20087+
#endif
2005720088
#ifdef HAVE_LIBNUMA
2005820089
MYSQL_SYSVAR(numa_interleave),
2005920090
#endif /* HAVE_LIBNUMA */

storage/innobase/include/fil0fil.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ enum srv_flush_t
7777
#endif
7878
};
7979

80+
/** Possible values of innodb_linux_aio */
81+
#ifdef __linux__
82+
enum srv_linux_aio_t
83+
{
84+
/** auto, io_uring first and then aio */
85+
SRV_LINUX_AIO_AUTO,
86+
/** io_uring */
87+
SRV_LINUX_AIO_IO_URING,
88+
/** aio (libaio interface) */
89+
SRV_LINUX_AIO_LIBAIO
90+
};
91+
#endif
92+
8093
/** innodb_flush_method */
8194
extern ulong srv_file_flush_method;
8295

storage/innobase/include/srv0srv.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ OS (provided we compiled Innobase with it in), otherwise we will
178178
use simulated aio.
179179
Currently we support native aio on windows and linux */
180180
extern my_bool srv_use_native_aio;
181+
182+
#ifdef __linux__
183+
/* This enum is defined which linux native io method to use */
184+
extern ulong srv_linux_aio_method;
185+
#endif
186+
181187
extern my_bool srv_numa_interleave;
182188

183189
/* Use atomic writes i.e disable doublewrite buffer */

0 commit comments

Comments
 (0)