Commit 9ecd7665 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.5 into 10.6

parents d79c3f32 e8217d07
......@@ -552,7 +552,7 @@ void CorruptedPages::zero_out_free_pages()
*page_it, space_name.c_str());
}
}
space->flush();
space->flush<true>();
space->release();
}
m_spaces.swap(non_free_pages);
......@@ -2120,9 +2120,9 @@ static bool innodb_init_param()
srv_buf_pool_size = (ulint) xtrabackup_use_memory;
srv_buf_pool_chunk_unit = (ulong)srv_buf_pool_size;
srv_n_file_io_threads = (ulint) innobase_file_io_threads;
srv_n_read_io_threads = innobase_read_io_threads;
srv_n_write_io_threads = innobase_write_io_threads;
srv_n_file_io_threads = (uint) innobase_file_io_threads;
srv_n_read_io_threads = (uint) innobase_read_io_threads;
srv_n_write_io_threads = (uint) innobase_write_io_threads;
srv_max_n_open_files = ULINT_UNDEFINED - 5;
......@@ -4265,8 +4265,10 @@ static bool xtrabackup_backup_func()
xb_fil_io_init();
srv_n_file_io_threads = srv_n_read_io_threads;
os_aio_init(srv_n_read_io_threads, srv_n_write_io_threads,
SRV_MAX_N_PENDING_SYNC_IOS);
if (os_aio_init()) {
msg("Error: cannot initialize AIO subsystem");
goto fail;
}
log_sys.create();
log_sys.log.create();
......
......@@ -371,15 +371,6 @@
VARIABLE_COMMENT Number of pages that must be accessed sequentially for InnoDB to trigger a readahead.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 64
@@ -1609,7 +1609,7 @@
SESSION_VALUE NULL
DEFAULT_VALUE 4
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Number of background read I/O threads in InnoDB.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 64
@@ -1705,7 +1705,7 @@
SESSION_VALUE NULL
DEFAULT_VALUE 1048576
......@@ -429,12 +420,3 @@
VARIABLE_COMMENT Number of undo tablespaces to use.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 127
@@ -2053,7 +2053,7 @@
SESSION_VALUE NULL
DEFAULT_VALUE 4
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Number of background write I/O threads in InnoDB.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 64
......@@ -1429,7 +1429,7 @@ VARIABLE_NAME INNODB_READ_IO_THREADS
SESSION_VALUE NULL
DEFAULT_VALUE 4
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Number of background read I/O threads in InnoDB.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 64
......@@ -1813,9 +1813,9 @@ VARIABLE_NAME INNODB_WRITE_IO_THREADS
SESSION_VALUE NULL
DEFAULT_VALUE 4
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Number of background write I/O threads in InnoDB.
NUMERIC_MIN_VALUE 1
NUMERIC_MIN_VALUE 2
NUMERIC_MAX_VALUE 64
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
......
......@@ -642,7 +642,7 @@ void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request)
mysql_mutex_unlock(&mutex);
/* Now flush the doublewrite buffer data to disk */
fil_system.sys_space->flush();
fil_system.sys_space->flush<false>();
/* The writes have been flushed to disk now and in recovery we will
find them in the doublewrite buffer blocks. Next, write the data pages. */
......
......@@ -496,18 +496,16 @@ void fil_space_t::flush_low()
{
ut_ad(!mutex_own(&fil_system.mutex));
uint32_t n= 0;
while (!n_pending.compare_exchange_strong(n, (n + 1) | NEEDS_FSYNC,
uint32_t n= 1;
while (!n_pending.compare_exchange_strong(n, n | NEEDS_FSYNC,
std::memory_order_acquire,
std::memory_order_relaxed))
{
ut_ad(n & PENDING);
if (n & STOPPING)
return;
if (!(n & NEEDS_FSYNC))
continue;
if (acquire_low() & STOPPING)
return;
break;
if (n & NEEDS_FSYNC)
break;
}
fil_n_pending_tablespace_flushes++;
......@@ -535,7 +533,6 @@ void fil_space_t::flush_low()
}
clear_flush();
release();
fil_n_pending_tablespace_flushes--;
}
......@@ -632,8 +629,10 @@ fil_space_extend_must_retry(
case TRX_SYS_SPACE:
srv_sys_space.set_last_file_size(pages_in_MiB);
do_flush:
space->reacquire();
mutex_exit(&fil_system.mutex);
space->flush_low();
space->release();
mutex_enter(&fil_system.mutex);
break;
default:
......@@ -3395,8 +3394,10 @@ void fil_flush_file_spaces()
{
if (space.needs_flush_not_stopping())
{
space.reacquire();
mutex_exit(&fil_system.mutex);
space.flush_low();
space.release();
goto rescan;
}
}
......
......@@ -3486,9 +3486,6 @@ static int innodb_init_params()
}
#ifdef LINUX_NATIVE_AIO
if (srv_use_native_aio) {
ib::info() << "Using Linux native AIO";
}
#elif !defined _WIN32
/* Currently native AIO is supported only on windows and linux
and that also when the support is compiled in. In all other
......@@ -18887,15 +18884,15 @@ static MYSQL_SYSVAR_BOOL(optimize_fulltext_only, innodb_optimize_fulltext_only,
"Only optimize the Fulltext index of the table",
NULL, NULL, FALSE);
static MYSQL_SYSVAR_ULONG(read_io_threads, srv_n_read_io_threads,
static MYSQL_SYSVAR_UINT(read_io_threads, srv_n_read_io_threads,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Number of background read I/O threads in InnoDB.",
NULL, NULL, 4, 1, 64, 0);
static MYSQL_SYSVAR_ULONG(write_io_threads, srv_n_write_io_threads,
static MYSQL_SYSVAR_UINT(write_io_threads, srv_n_write_io_threads,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Number of background write I/O threads in InnoDB.",
NULL, NULL, 4, 1, 64, 0);
NULL, NULL, 4, 2, 64, 0);
static MYSQL_SYSVAR_ULONG(force_recovery, srv_force_recovery,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
......
......@@ -975,7 +975,7 @@ struct fil_space_t final
fil_io_t io(const IORequest &type, os_offset_t offset, size_t len,
void *buf, buf_page_t *bpage= nullptr);
/** Flush pending writes from the file system cache to the file. */
inline void flush();
template<bool have_reference> inline void flush();
/** Flush pending writes from the file system cache to the file. */
void flush_low();
......@@ -1490,18 +1490,23 @@ inline void fil_space_t::set_stopping(bool stopping)
}
/** Flush pending writes from the file system cache to the file. */
inline void fil_space_t::flush()
template<bool have_reference> inline void fil_space_t::flush()
{
ut_ad(!mutex_own(&fil_system.mutex));
ut_ad(!have_reference || (pending() & PENDING));
ut_ad(purpose == FIL_TYPE_TABLESPACE || purpose == FIL_TYPE_IMPORT);
if (srv_file_flush_method == SRV_O_DIRECT_NO_FSYNC)
{
ut_ad(!is_in_unflushed_spaces);
ut_ad(!needs_flush());
}
else
else if (have_reference)
flush_low();
else if (!(acquire_low() & STOPPING))
{
flush_low();
release();
}
}
/** @return the size in pages (0 if unreadable) */
......
......@@ -1135,21 +1135,9 @@ void
unit_test_os_file_get_parent_dir();
#endif /* UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR */
/** Initializes the asynchronous io system. Creates one array each for ibuf
and log i/o. Also creates one array each for read and write where each
array is divided logically into n_read_segs and n_write_segs
respectively. The caller must create an i/o handler thread for each
segment in these arrays. This function also creates the sync array.
No i/o handler thread needs to be created for that
@param[in] n_read_segs number of reader threads
@param[in] n_write_segs number of writer threads
@param[in] n_slots_sync number of slots in the sync aio array */
bool
os_aio_init(
ulint n_read_segs,
ulint n_write_segs,
ulint n_slots_sync);
/**
Initializes the asynchronous io system. */
int os_aio_init();
/**
Frees the asynchronous io system. */
......
......@@ -337,11 +337,11 @@ extern ulong srv_buf_pool_load_pages_abort;
/** Lock table size in bytes */
extern ulint srv_lock_table_size;
extern ulint srv_n_file_io_threads;
extern uint srv_n_file_io_threads;
extern my_bool srv_random_read_ahead;
extern ulong srv_read_ahead_threshold;
extern ulong srv_n_read_io_threads;
extern ulong srv_n_write_io_threads;
extern uint srv_n_read_io_threads;
extern uint srv_n_write_io_threads;
/* Defragmentation, Origianlly facebook default value is 100, but it's too high */
#define SRV_DEFRAGMENT_FREQUENCY_DEFAULT 40
......
......@@ -3890,7 +3890,6 @@ versions where native aio is supported it won't work on tmpfs. In such
cases we can't use native aio.
@return: true if supported, false otherwise. */
#include <libaio.h>
static bool is_linux_native_aio_supported()
{
File fd;
......@@ -4012,34 +4011,41 @@ static bool is_linux_native_aio_supported()
}
#endif
bool os_aio_init(ulint n_reader_threads, ulint n_writer_threads, ulint)
int os_aio_init()
{
int max_write_events= int(n_writer_threads * OS_AIO_N_PENDING_IOS_PER_THREAD);
int max_read_events= int(n_reader_threads * OS_AIO_N_PENDING_IOS_PER_THREAD);
int max_events = max_read_events + max_write_events;
int ret;
int max_write_events= int(srv_n_write_io_threads *
OS_AIO_N_PENDING_IOS_PER_THREAD);
int max_read_events= int(srv_n_read_io_threads *
OS_AIO_N_PENDING_IOS_PER_THREAD);
int max_events= max_read_events + max_write_events;
int ret;
#if LINUX_NATIVE_AIO
if (srv_use_native_aio && !is_linux_native_aio_supported())
srv_use_native_aio = false;
if (srv_use_native_aio && !is_linux_native_aio_supported())
goto disable;
#endif
ret = srv_thread_pool->configure_aio(srv_use_native_aio, max_events);
if(ret) {
ut_a(srv_use_native_aio);
srv_use_native_aio = false;
ret= srv_thread_pool->configure_aio(srv_use_native_aio, max_events);
#ifdef LINUX_NATIVE_AIO
ib::info() << "Linux native AIO disabled";
if (ret)
{
ut_ad(srv_use_native_aio);
disable:
ib::warn() << "Linux Native AIO disabled.";
srv_use_native_aio= false;
ret= srv_thread_pool->configure_aio(false, max_events);
}
#endif
ret = srv_thread_pool->configure_aio(srv_use_native_aio, max_events);
DBUG_ASSERT(!ret);
}
read_slots = new io_slots(max_read_events, (uint)n_reader_threads);
write_slots = new io_slots(max_write_events, (uint)n_writer_threads);
return true;
if (!ret)
{
read_slots= new io_slots(max_read_events, srv_n_read_io_threads);
write_slots= new io_slots(max_write_events, srv_n_write_io_threads);
}
return ret;
}
void os_aio_free()
{
srv_thread_pool->disable_aio();
......@@ -4157,8 +4163,8 @@ os_aio_print(FILE* file)
time_t current_time;
double time_elapsed;
for (ulint i = 0; i < srv_n_file_io_threads; ++i) {
fprintf(file, "I/O thread " ULINTPF " state: %s (%s)",
for (uint i = 0; i < srv_n_file_io_threads; ++i) {
fprintf(file, "I/O thread %u state: %s (%s)",
i,
srv_io_thread_op_info[i],
srv_io_thread_function[i]);
......
......@@ -545,7 +545,7 @@ row_quiesce_table_start(
if (!trx_is_interrupted(trx)) {
/* Ensure that all asynchronous IO is completed. */
os_aio_wait_until_no_pending_writes();
table->space->flush();
table->space->flush<false>();
if (row_quiesce_write_cfg(table, trx->mysql_thd)
!= DB_SUCCESS) {
......
......@@ -228,9 +228,9 @@ ulint srv_lock_table_size = ULINT_MAX;
ulong srv_idle_flush_pct;
/** innodb_read_io_threads */
ulong srv_n_read_io_threads;
uint srv_n_read_io_threads;
/** innodb_write_io_threads */
ulong srv_n_write_io_threads;
uint srv_n_write_io_threads;
/** innodb_random_read_ahead */
my_bool srv_random_read_ahead;
......
......@@ -111,7 +111,7 @@ lsn_t srv_shutdown_lsn;
ibool srv_start_raw_disk_in_use;
/** Number of IO threads to use */
ulint srv_n_file_io_threads;
uint srv_n_file_io_threads;
/** UNDO tablespaces starts with space id. */
ulint srv_undo_space_id_start;
......@@ -1190,9 +1190,7 @@ dberr_t srv_start(bool create_new_db)
return(srv_init_abort(err));
}
srv_n_file_io_threads = srv_n_read_io_threads;
srv_n_file_io_threads += srv_n_write_io_threads;
srv_n_file_io_threads = srv_n_read_io_threads + srv_n_write_io_threads;
if (!srv_read_only_mode) {
/* Add the log and ibuf IO threads. */
......@@ -1204,15 +1202,18 @@ dberr_t srv_start(bool create_new_db)
ut_a(srv_n_file_io_threads <= SRV_MAX_N_IO_THREADS);
if (!os_aio_init(srv_n_read_io_threads,
srv_n_write_io_threads,
SRV_MAX_N_PENDING_SYNC_IOS)) {
if (os_aio_init()) {
ib::error() << "Cannot initialize AIO sub-system";
return(srv_init_abort(DB_ERROR));
}
#ifdef LINUX_NATIVE_AIO
if (srv_use_native_aio) {
ib::info() << "Using Linux native AIO";
}
#endif
fil_system.create(srv_file_per_table ? 50000 : 5000);
ib::info() << "Initializing buffer pool, total size = "
......
......@@ -220,7 +220,7 @@ class thread_pool
{
if (use_native_aio)
m_aio.reset(create_native_aio(max_io));
if (!m_aio)
else
m_aio.reset(create_simulated_aio(this));
return !m_aio ? -1 : 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment