From 44d8fe96461c0605a53159fcdc4bf04a8e5c52b3 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 27 Jun 2012 17:13:12 +0300 Subject: Don't abort InnoDB/XtraDB if one can't allocate resources for AIO - Better error messages This fixes that one again can run the test systems with many threads without having to increase fs.aio-max-nr. mysql-test/include/mtr_check.sql: Ignore the INNODB_USE_NATIVE_AIO variable (may change during execution) mysql-test/mysql-test-run.pl: Ignore warnings for failure to setup AIO storage/innobase/os/os0file.c: Continue without AIO even if we can't allocate resources for AIO storage/xtradb/os/os0file.c: Continue without AIO even if we can't allocate resources for AIO storage/xtradb/srv/srv0start.c: Give an error message (instead of core dump) if AIO can't be initialized --- mysql-test/include/mtr_check.sql | 1 + mysql-test/mysql-test-run.pl | 3 +++ storage/innobase/os/os0file.c | 23 +++++++++++++++++------ storage/xtradb/os/os0file.c | 23 +++++++++++++++++------ storage/xtradb/srv/srv0start.c | 18 ++++++++++++++---- 5 files changed, 52 insertions(+), 16 deletions(-) diff --git a/mysql-test/include/mtr_check.sql b/mysql-test/include/mtr_check.sql index 82c0514b7cd..6c1a3513324 100644 --- a/mysql-test/include/mtr_check.sql +++ b/mysql-test/include/mtr_check.sql @@ -30,6 +30,7 @@ BEGIN WHERE variable_name NOT IN ('timestamp', 'innodb_file_format_max') AND variable_name not like "Last_IO_Err*" AND variable_name != 'INNODB_IBUF_MAX_SIZE' + AND variable_name != 'INNODB_USE_NATIVE_AIO' ORDER BY variable_name; -- Dump all databases, there should be none diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 6e463f35bf5..a2802916fe4 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -4738,6 +4738,9 @@ sub extract_warning_lines ($$) { qr|Aborted connection|, qr|table.*is full|, qr|Linux Native AIO|, # warning that aio does not work on /dev/shm + qr|Error: io_setup\(\) failed|, + qr|Warning: io_setup\(\) failed|, + qr|Warning: io_setup\(\) attempt|, ); my $matched_lines= []; diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index ed5b3116daa..15e66167f26 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -3361,12 +3361,23 @@ os_aio_array_create( if (!os_aio_linux_create_io_ctx(n/n_segments, &array->aio_ctx[i])) { /* If something bad happened during aio setup - we should call it a day and return right away. - We don't care about any leaks because a failure - to initialize the io subsystem means that the - server (or atleast the innodb storage engine) - is not going to startup. */ - return(NULL); + we disable linux native aio. + The disadvantage will be a small memory leak + at shutdown but that's ok compared to a crash + or a not working server. + This frequently happens when running the test suite + with many threads on a system with low fs.aio-max-nr! + */ + + fprintf(stderr, + " InnoDB: Warning: Linux Native AIO disabled " + "because os_aio_linux_create_io_ctx() " + "failed. To get rid of this warning you can " + "try increasing system " + "fs.aio-max-nr to 1048576 or larger or " + "setting innodb_use_native_aio = 0 in my.cnf\n"); + srv_use_native_aio = FALSE; + goto skip_native_aio; } } diff --git a/storage/xtradb/os/os0file.c b/storage/xtradb/os/os0file.c index eefe17df740..5d249d52ce9 100644 --- a/storage/xtradb/os/os0file.c +++ b/storage/xtradb/os/os0file.c @@ -3463,12 +3463,23 @@ os_aio_array_create( if (!os_aio_linux_create_io_ctx(n/n_segments, &array->aio_ctx[i])) { /* If something bad happened during aio setup - we should call it a day and return right away. - We don't care about any leaks because a failure - to initialize the io subsystem means that the - server (or atleast the innodb storage engine) - is not going to startup. */ - return(NULL); + we disable linux native aio. + The disadvantage will be a small memory leak + at shutdown but that's ok compared to a crash + or a not working server. + This frequently happens when running the test suite + with many threads on a system with low fs.aio-max-nr! + */ + + fprintf(stderr, + " InnoDB: Warning: Linux Native AIO disabled " + "because os_aio_linux_create_io_ctx() " + "failed. To get rid of this warning you can " + "try increasing system " + "fs.aio-max-nr to 1048576 or larger or " + "setting innodb_use_native_aio = 0 in my.cnf\n"); + srv_use_native_aio = FALSE; + goto skip_native_aio; } } diff --git a/storage/xtradb/srv/srv0start.c b/storage/xtradb/srv/srv0start.c index 59697731e6c..75e8097ee0b 100644 --- a/storage/xtradb/srv/srv0start.c +++ b/storage/xtradb/srv/srv0start.c @@ -1509,10 +1509,20 @@ innobase_start_or_create_for_mysql(void) } # endif /* __WIN__ */ - os_aio_init(io_limit, - srv_n_read_io_threads, - srv_n_write_io_threads, - SRV_MAX_N_PENDING_SYNC_IOS); + if (!os_aio_init(io_limit, + srv_n_read_io_threads, + srv_n_write_io_threads, + SRV_MAX_N_PENDING_SYNC_IOS)) + { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Fatal error: cannot initialize AIO" + " sub-system\n"); +#if defined(LINUX_NATIVE_AIO) + fprintf(stderr, "You can try increasing system fs.aio-max-nr to 1048576 or larger or setting innodb_use_native_aio = 0 in my.cnf\n"); +#endif + return(DB_ERROR); + } fil_init(srv_file_per_table ? 50000 : 5000, srv_max_n_open_files); -- cgit v1.2.1