summaryrefslogtreecommitdiff
path: root/storage/xtradb/srv/srv0srv.c
diff options
context:
space:
mode:
Diffstat (limited to 'storage/xtradb/srv/srv0srv.c')
-rw-r--r--storage/xtradb/srv/srv0srv.c149
1 files changed, 148 insertions, 1 deletions
diff --git a/storage/xtradb/srv/srv0srv.c b/storage/xtradb/srv/srv0srv.c
index 637b9e2df28..3184308f573 100644
--- a/storage/xtradb/srv/srv0srv.c
+++ b/storage/xtradb/srv/srv0srv.c
@@ -211,6 +211,11 @@ UNIV_INTERN ulint srv_buf_pool_curr_size = 0;
UNIV_INTERN ulint srv_mem_pool_size = ULINT_MAX;
UNIV_INTERN ulint srv_lock_table_size = ULINT_MAX;
+/* key value for shm */
+UNIV_INTERN uint srv_buffer_pool_shm_key = 0;
+UNIV_INTERN ibool srv_buffer_pool_shm_is_reused = FALSE;
+UNIV_INTERN ibool srv_buffer_pool_shm_checksum = TRUE;
+
/* This parameter is deprecated. Use srv_n_io_[read|write]_threads
instead. */
UNIV_INTERN ulint srv_n_file_io_threads = ULINT_MAX;
@@ -221,6 +226,9 @@ UNIV_INTERN ulint srv_n_write_io_threads = ULINT_MAX;
UNIV_INTERN ulint srv_page_size_shift = 0;
UNIV_INTERN ulint srv_page_size = 0;
+/* The log block size */
+UNIV_INTERN ulint srv_log_block_size = 0;
+
/* User settable value of the number of pages that must be present
in the buffer cache and accessed sequentially for InnoDB to trigger a
readahead request. */
@@ -2683,15 +2691,26 @@ srv_master_thread(
ulint n_pages_purged = 0;
ulint n_bytes_merged;
ulint n_pages_flushed;
+ ulint n_pages_flushed_prev = 0;
ulint n_bytes_archived;
ulint n_tables_to_drop;
ulint n_ios;
ulint n_ios_old;
ulint n_ios_very_old;
ulint n_pend_ios;
+ ulint next_itr_time;
+ ulint prev_adaptive_checkpoint = ULINT_UNDEFINED;
+ ulint inner_loop = 0;
ibool skip_sleep = FALSE;
ulint i;
+ struct t_prev_flush_info_struct {
+ ulint count;
+ unsigned space:32;
+ unsigned offset:32;
+ ib_uint64_t oldest_modification;
+ } prev_flush_info;
+
ib_uint64_t lsn_old;
ib_uint64_t oldest_lsn;
@@ -2704,6 +2723,7 @@ srv_master_thread(
srv_main_thread_id = os_thread_pf(os_thread_get_curr_id());
+ memset(&prev_flush_info, 0, sizeof(prev_flush_info));
mutex_enter(&kernel_mutex);
srv_table_reserve_slot(SRV_MASTER);
@@ -2723,6 +2743,8 @@ loop:
n_ios_very_old = log_sys->n_log_ios + buf_pool->stat.n_pages_read
+ buf_pool->stat.n_pages_written;
+ n_pages_flushed= 0;
+
mutex_enter(&kernel_mutex);
/* Store the user activity counter at the start of this loop */
@@ -2741,15 +2763,20 @@ loop:
srv_last_log_flush_time = time(NULL);
skip_sleep = FALSE;
+ next_itr_time = ut_time_ms() + 1000;
+
for (i = 0; i < 10; i++) {
+ ulint cur_time = ut_time_ms();
+
n_ios_old = log_sys->n_log_ios + buf_pool->stat.n_pages_read
+ buf_pool->stat.n_pages_written;
srv_main_thread_op_info = "sleeping";
srv_main_1_second_loops++;
if (!skip_sleep) {
+ if (next_itr_time > cur_time) {
- os_event_wait_time(srv_shutdown_event, 1000000);
+ os_event_wait_time(srv_shutdown_event, ut_min(1000000, (next_itr_time - cur_time) * 1000));
srv_main_sleeps++;
/*
@@ -2766,6 +2793,10 @@ loop:
*/
}
+ /* Each iteration should happen at 1 second interval. */
+ next_itr_time = ut_time_ms() + 1000;
+ }
+
skip_sleep = FALSE;
/* ALTER TABLE in MySQL requires on Unix that the table handler
@@ -2828,6 +2859,7 @@ loop:
mutex_enter(&(log_sys->mutex));
lsn_old = log_sys->lsn;
mutex_exit(&(log_sys->mutex));
+ prev_adaptive_checkpoint = ULINT_UNDEFINED;
} else if (srv_adaptive_flushing) {
/* Try to keep the rate of flushing of dirty
@@ -2853,6 +2885,7 @@ loop:
mutex_enter(&(log_sys->mutex));
lsn_old = log_sys->lsn;
mutex_exit(&(log_sys->mutex));
+ prev_adaptive_checkpoint = ULINT_UNDEFINED;
} else if (srv_adaptive_checkpoint == 1) {
/* adaptive_flushing option is prior to adaptive_checkpoint option, for now */
@@ -2896,6 +2929,7 @@ loop:
mutex_exit(&(log_sys->mutex));
}
}
+ prev_adaptive_checkpoint = 1;
} else if (srv_adaptive_checkpoint == 2) {
/* Try to keep modified age not to exceed
@@ -2978,11 +3012,124 @@ retry_flush_batch:
mutex_exit(&(log_sys->mutex));
}
}
+ prev_adaptive_checkpoint = 2;
+ } else if (srv_adaptive_checkpoint == 3) {
+ buf_page_t* bpage;
+ ib_uint64_t lsn;
+
+ mutex_enter(&(log_sys->mutex));
+ oldest_lsn = buf_pool_get_oldest_modification();
+ lsn = log_sys->lsn;
+ mutex_exit(&(log_sys->mutex));
+ /* upper loop/sec. (x10) */
+ next_itr_time -= 900; /* 1000 - 900 == 100 */
+ inner_loop++;
+ if (inner_loop < 10) {
+ i--;
+ } else {
+ inner_loop = 0;
+ }
+
+ if (prev_adaptive_checkpoint == 3) {
+ lint n_flush;
+ lint blocks_sum, new_blocks_sum, flushed_blocks_sum;
+
+ blocks_sum = new_blocks_sum = flushed_blocks_sum = 0;
+
+ /* prev_flush_info should be the previous loop's */
+ {
+ lint blocks_num, new_blocks_num, flushed_blocks_num;
+ ibool found;
+
+ blocks_num = UT_LIST_GET_LEN(buf_pool->flush_list);
+ bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
+ new_blocks_num = 0;
+
+ found = FALSE;
+ while (bpage != NULL) {
+ if (prev_flush_info.space == bpage->space
+ && prev_flush_info.offset == bpage->offset
+ && prev_flush_info.oldest_modification
+ == bpage->oldest_modification) {
+ found = TRUE;
+ break;
+ }
+ bpage = UT_LIST_GET_NEXT(flush_list, bpage);
+ new_blocks_num++;
+ }
+ if (!found) {
+ new_blocks_num = blocks_num;
+ }
+
+ flushed_blocks_num = new_blocks_num + prev_flush_info.count
+ - blocks_num;
+ if (flushed_blocks_num < 0) {
+ flushed_blocks_num = 0;
+ }
+
+ bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
+
+ prev_flush_info.count = UT_LIST_GET_LEN(buf_pool->flush_list);
+ if (bpage) {
+ prev_flush_info.space = bpage->space;
+ prev_flush_info.offset = bpage->offset;
+ prev_flush_info.oldest_modification = bpage->oldest_modification;
+ } else {
+ prev_flush_info.space = 0;
+ prev_flush_info.offset = 0;
+ prev_flush_info.oldest_modification = 0;
+ }
+
+ new_blocks_sum += new_blocks_num;
+ flushed_blocks_sum += flushed_blocks_num;
+ blocks_sum += blocks_num;
+ }
+
+ n_flush = (lint) (blocks_sum * (lsn - lsn_old) / log_sys->max_modified_age_async);
+ if ((ulint) flushed_blocks_sum > n_pages_flushed_prev) {
+ n_flush -= (flushed_blocks_sum - n_pages_flushed_prev);
+ }
+
+ if (n_flush > 0) {
+ n_flush++;
+ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, n_flush,
+ oldest_lsn + (lsn - lsn_old));
+ } else {
+ n_pages_flushed = 0;
+ }
+ } else {
+ /* store previous first pages of the flush_list */
+ {
+ bpage = UT_LIST_GET_FIRST(buf_pool->flush_list);
+
+ prev_flush_info.count = UT_LIST_GET_LEN(buf_pool->flush_list);
+ if (bpage) {
+ prev_flush_info.space = bpage->space;
+ prev_flush_info.offset = bpage->offset;
+ prev_flush_info.oldest_modification = bpage->oldest_modification;
+ } else {
+ prev_flush_info.space = 0;
+ prev_flush_info.offset = 0;
+ prev_flush_info.oldest_modification = 0;
+ }
+ }
+ n_pages_flushed = 0;
+ }
+
+ lsn_old = lsn;
+ prev_adaptive_checkpoint = 3;
} else {
mutex_enter(&(log_sys->mutex));
lsn_old = log_sys->lsn;
mutex_exit(&(log_sys->mutex));
+ prev_adaptive_checkpoint = ULINT_UNDEFINED;
+ }
+
+ if (n_pages_flushed == ULINT_UNDEFINED) {
+ n_pages_flushed_prev = 0;
+ } else {
+ n_pages_flushed_prev = n_pages_flushed;
}
if (srv_activity_count == old_activity_count) {