63#include <drizzled/error.h>
64#include <drizzled/errmsg_print.h>
94UNIV_INTERN uint srv_lower_case_table_names = 0;
98UNIV_INTERN ulint srv_activity_count = 0;
101UNIV_INTERN ulint srv_fatal_semaphore_wait_threshold = 600;
105UNIV_INTERN ulint srv_dml_needed_delay = 0;
107UNIV_INTERN ibool srv_lock_timeout_active = FALSE;
108UNIV_INTERN ibool srv_monitor_active = FALSE;
109UNIV_INTERN ibool srv_error_monitor_active = FALSE;
111UNIV_INTERN
const char* srv_main_thread_op_info =
"";
118UNIV_INTERN
char* srv_data_home = NULL;
119#ifdef UNIV_LOG_ARCHIVE
120UNIV_INTERN
char* srv_arch_dir = NULL;
134# error "DICT_TF_FORMAT_51 must be 0!"
144UNIV_INTERN my_bool srv_use_native_aio = TRUE;
158UNIV_INTERN ibool srv_use_native_conditions = FALSE;
161UNIV_INTERN ulint srv_n_data_files = 0;
162UNIV_INTERN
char** srv_data_file_names = NULL;
164UNIV_INTERN ulint* srv_data_file_sizes = NULL;
167UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE;
170UNIV_INTERN ulint srv_last_file_size_max = 0;
173UNIV_INTERN
unsigned int srv_auto_extend_increment = 8;
174UNIV_INTERN ulint* srv_data_file_is_raw_partition = NULL;
179UNIV_INTERN ibool srv_created_new_raw = FALSE;
181UNIV_INTERN
char** srv_log_group_home_dirs = NULL;
183UNIV_INTERN ulint srv_n_log_groups = ULINT_MAX;
184UNIV_INTERN ulint srv_n_log_files = ULINT_MAX;
186UNIV_INTERN ulint srv_log_file_size = ULINT_MAX;
188UNIV_INTERN ulint srv_log_buffer_size = ULINT_MAX;
189UNIV_INTERN ulong srv_flush_log_at_trx_commit = 1;
193UNIV_INTERN
bool srv_adaptive_flushing = TRUE;
197#define MAX_MUTEX_NOWAIT 20
203#define MUTEX_NOWAIT(mutex_skipped) ((mutex_skipped) < MAX_MUTEX_NOWAIT)
207#if defined(BUILD_DRIZZLE)
212 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
213, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
214, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
215, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
216, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27
217, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F
218, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37
219, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F
220, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47
221, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F
222, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57
223, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F
224, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47
225, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F
226, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57
227, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F
228, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87
229, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F
230, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97
231, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F
232, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7
233, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF
234, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7
235, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF
236, 0x41, 0x41, 0x41, 0x41, 0x5C, 0x5B, 0x5C, 0x43
237, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49
238, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x5D, 0xD7
239, 0xD8, 0x55, 0x55, 0x55, 0x59, 0x59, 0xDE, 0xDF
240, 0x41, 0x41, 0x41, 0x41, 0x5C, 0x5B, 0x5C, 0x43
241, 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49
242, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x5D, 0xF7
243, 0xD8, 0x55, 0x55, 0x55, 0x59, 0x59, 0xDE, 0xFF
251UNIV_INTERN my_bool srv_use_sys_malloc = TRUE;
261UNIV_INTERN ulint srv_mem_pool_size = ULINT_MAX;
262UNIV_INTERN ulint srv_lock_table_size = ULINT_MAX;
266UNIV_INTERN ulint srv_n_file_io_threads = ULINT_MAX;
267UNIV_INTERN ulint srv_n_read_io_threads = ULINT_MAX;
268UNIV_INTERN ulint srv_n_write_io_threads = ULINT_MAX;
271UNIV_INTERN ulint srv_page_size_shift = 0;
272UNIV_INTERN ulint srv_page_size = 0;
275UNIV_INTERN uint32_t srv_log_block_size = 0;
280UNIV_INTERN ulong srv_read_ahead_threshold = 56;
282#ifdef UNIV_LOG_ARCHIVE
283UNIV_INTERN ibool srv_log_archive_on = FALSE;
284UNIV_INTERN ibool srv_archive_recovery = 0;
285UNIV_INTERN ib_uint64_t srv_archive_recovery_limit_lsn;
296UNIV_INTERN ulong srv_insert_buffer_batch_size = 20;
298UNIV_INTERN
char* srv_file_flush_method_str = NULL;
302UNIV_INTERN ulint srv_max_n_open_files = 300;
305UNIV_INTERN ulong srv_io_capacity = 200;
312UNIV_INTERN ulong srv_max_buf_pool_modified_pct = 75;
315UNIV_INTERN ulong srv_n_purge_threads = 0;
318UNIV_INTERN ulong srv_purge_batch_size = 20;
321UNIV_INTERN ulong srv_rollback_segments = TRX_SYS_N_RSEGS;
324UNIV_INTERN ulint srv_data_read = 0;
329ulong srv_innodb_stats_method = SRV_STATS_NULLS_EQUAL;
332UNIV_INTERN ulint srv_data_written = 0;
335UNIV_INTERN ulint srv_log_write_requests = 0;
338UNIV_INTERN ulint srv_log_writes = 0;
341UNIV_INTERN ulint srv_os_log_written = 0;
344UNIV_INTERN ulint srv_os_log_pending_writes = 0;
348UNIV_INTERN ulint srv_log_waits = 0;
352UNIV_INTERN ulint srv_dblwr_writes = 0;
356UNIV_INTERN ulint srv_dblwr_pages_written = 0;
359UNIV_INTERN ulint srv_buf_pool_write_requests = 0;
364UNIV_INTERN ulint srv_buf_pool_wait_free = 0;
368UNIV_INTERN ulint srv_buf_pool_flushed = 0;
383UNIV_INTERN ulint srv_force_recovery = 0;
389UNIV_INTERN ulint srv_max_n_threads = 0;
399UNIV_INTERN ulong srv_thread_concurrency = 0;
407UNIV_INTERN lint srv_conc_n_threads = 0;
410UNIV_INTERN ulint srv_conc_n_waiting_threads = 0;
430UNIV_INTERN srv_conc_slot_t* srv_conc_slots;
434#define SRV_FREE_TICKETS_TO_ENTER srv_n_free_tickets_to_enter
435#define SRV_THREAD_SLEEP_DELAY srv_thread_sleep_delay
441UNIV_INTERN ulint srv_fast_shutdown = 0;
444UNIV_INTERN ibool srv_innodb_status = FALSE;
448UNIV_INTERN ib_uint64_t srv_stats_sample_pages = 8;
450UNIV_INTERN ibool srv_use_doublewrite_buf = TRUE;
451UNIV_INTERN ibool srv_use_checksums = TRUE;
453UNIV_INTERN ulong srv_replication_delay = 0;
455UNIV_INTERN uint64_t srv_ibuf_max_size = 0;
456UNIV_INTERN uint32_t srv_ibuf_active_contract = 0;
457UNIV_INTERN uint32_t srv_ibuf_accel_rate = 100;
459#define PCT_IBUF_IO(pct) (srv_io_capacity * srv_ibuf_accel_rate \
462UNIV_INTERN uint32_t srv_checkpoint_age_target = 0;
463UNIV_INTERN uint32_t srv_flush_neighbor_pages = 1;
465UNIV_INTERN uint32_t srv_read_ahead = 3;
466UNIV_INTERN uint32_t srv_adaptive_flushing_method = 0;
470UNIV_INTERN ibool srv_read_only = FALSE;
471UNIV_INTERN ibool srv_fake_write = FALSE;
472UNIV_INTERN ibool srv_apply_log_only = FALSE;
475UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;
476UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;
477UNIV_INTERN ulong srv_thread_sleep_delay = 10000;
478UNIV_INTERN ulong srv_spin_wait_delay = 6;
479UNIV_INTERN ibool srv_priority_boost = TRUE;
482UNIV_INTERN ibool srv_print_thread_releases = FALSE;
483UNIV_INTERN ibool srv_print_lock_waits = FALSE;
484UNIV_INTERN ibool srv_print_buf_io = FALSE;
485UNIV_INTERN ibool srv_print_log_io = FALSE;
486UNIV_INTERN ibool srv_print_latch_waits = FALSE;
489UNIV_INTERN ulint srv_n_rows_inserted = 0;
490UNIV_INTERN ulint srv_n_rows_updated = 0;
491UNIV_INTERN ulint srv_n_rows_deleted = 0;
492UNIV_INTERN ulint srv_n_rows_read = 0;
494static ulint srv_n_rows_inserted_old = 0;
495static ulint srv_n_rows_updated_old = 0;
496static ulint srv_n_rows_deleted_old = 0;
497static ulint srv_n_rows_read_old = 0;
499UNIV_INTERN ulint srv_n_lock_wait_count = 0;
500UNIV_INTERN ulint srv_n_lock_wait_current_count = 0;
501UNIV_INTERN ib_int64_t srv_n_lock_wait_time = 0;
502UNIV_INTERN ulint srv_n_lock_max_wait_time = 0;
504UNIV_INTERN ulint srv_truncated_status_writes = 0;
510UNIV_INTERN ibool srv_print_verbose_log = TRUE;
511UNIV_INTERN ibool srv_print_innodb_monitor = FALSE;
512UNIV_INTERN ibool srv_print_innodb_lock_monitor = FALSE;
513UNIV_INTERN ibool srv_print_innodb_tablespace_monitor = FALSE;
514UNIV_INTERN ibool srv_print_innodb_table_monitor = FALSE;
519UNIV_INTERN
const char* srv_io_thread_op_info[SRV_MAX_N_IO_THREADS];
520UNIV_INTERN
const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
522UNIV_INTERN time_t srv_last_monitor_time;
524UNIV_INTERN
mutex_t srv_innodb_monitor_mutex;
527UNIV_INTERN
mutex_t srv_monitor_file_mutex;
531UNIV_INTERN mysql_pfs_key_t kernel_mutex_key;
533UNIV_INTERN mysql_pfs_key_t commit_id_mutex_key;
535UNIV_INTERN mysql_pfs_key_t srv_innodb_monitor_mutex_key;
537UNIV_INTERN mysql_pfs_key_t srv_monitor_file_mutex_key;
539UNIV_INTERN mysql_pfs_key_t srv_dict_tmpfile_mutex_key;
541UNIV_INTERN mysql_pfs_key_t srv_misc_tmpfile_mutex_key;
545UNIV_INTERN FILE* srv_monitor_file;
549UNIV_INTERN
mutex_t srv_dict_tmpfile_mutex;
551UNIV_INTERN FILE* srv_dict_tmpfile;
555UNIV_INTERN
mutex_t srv_misc_tmpfile_mutex;
557UNIV_INTERN FILE* srv_misc_tmpfile;
559UNIV_INTERN ulint srv_main_thread_process_no = 0;
560UNIV_INTERN ulint srv_main_thread_id = 0;
565static ulint srv_main_1_second_loops = 0;
567static ulint srv_main_sleeps = 0;
569static ulint srv_main_10_second_loops = 0;
571static ulint srv_main_background_loops = 0;
573static ulint srv_main_flush_loops = 0;
575static ulint srv_log_writes_and_flush = 0;
581static time_t srv_last_log_flush_time;
586#define SRV_PEND_IO_THRESHOLD (PCT_IO(3))
587#define SRV_RECENT_IO_ACTIVITY (PCT_IO(5))
588#define SRV_PAST_IO_ACTIVITY (PCT_IO(200))
775UNIV_INTERN
srv_slot_t* srv_mysql_table = NULL;
783UNIV_INTERN
os_event_t srv_lock_timeout_thread_event;
789UNIV_INTERN
byte srv_pad1[64];
791UNIV_INTERN
mutex_t* kernel_mutex_temp;
793UNIV_INTERN
mutex_t* commit_id_mutex_temp;
797UNIV_INTERN
byte srv_pad2[64];
807static ulint srv_meter_low_water[
SRV_MASTER + 1];
808static ulint srv_meter_high_water[
SRV_MASTER + 1];
809static ulint srv_meter_high_water2[
SRV_MASTER + 1];
810static ulint srv_meter_foreground[
SRV_MASTER + 1];
817srv_print_master_thread_info(
821 fprintf(file,
"srv_master_thread loops: %lu 1_second, %lu sleeps, "
822 "%lu 10_second, %lu background, %lu flush\n",
823 srv_main_1_second_loops, srv_main_sleeps,
824 srv_main_10_second_loops, srv_main_background_loops,
825 srv_main_flush_loops);
826 fprintf(file,
"srv_master_thread log flush and writes: %lu\n",
827 srv_log_writes_and_flush);
834UNIV_INTERN ulint srv_n_threads_active[
SRV_MASTER + 1];
835UNIV_INTERN ulint srv_n_threads[
SRV_MASTER + 1];
847 ut_a(i < SRV_MAX_N_IO_THREADS);
849 srv_io_thread_op_info[i] = str;
858srv_table_get_nth_slot(
862 ut_ad(mutex_own(&kernel_mutex));
863 ut_a(index < OS_THREAD_MAX_N);
865 return(
srv_sys->threads + index);
879 mutex_enter(&kernel_mutex);
883 n_threads += srv_n_threads[i];
886 mutex_exit(&kernel_mutex);
897srv_thread_type_validate(
921 ut_ad(srv_thread_type_validate(type));
931srv_table_reserve_slot(
938 ut_ad(srv_thread_type_validate(type));
939 ut_ad(mutex_own(&kernel_mutex));
942 slot = srv_table_get_nth_slot(i);
946 slot = srv_table_get_nth_slot(i);
952 ut_ad(srv_slot_get_type(slot) == type);
970 ut_ad(mutex_own(&kernel_mutex));
976 if (srv_print_thread_releases) {
978 "Suspending thread %lu to slot %lu\n",
980 (ulong) (slot -
srv_sys->threads));
983 type = srv_slot_get_type(slot);
987 ut_ad(srv_n_threads_active[type] > 0);
989 srv_n_threads_active[type]--;
1010 ut_ad(srv_thread_type_validate(type));
1012 ut_ad(mutex_own(&kernel_mutex));
1014 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1016 slot = srv_table_get_nth_slot(i);
1019 && srv_slot_get_type(slot) == type) {
1023 srv_n_threads_active[type]++;
1027 if (srv_print_thread_releases) {
1029 "Releasing thread %lu type %lu"
1031 (ulong) slot->
id, (ulong) type,
1057 ulint slot_no = ULINT_UNDEFINED;
1059 ut_ad(srv_thread_type_validate(type));
1060 mutex_enter(&kernel_mutex);
1062 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1065 slot = srv_table_get_nth_slot(i);
1067 if (slot->
in_use && slot->
type == (
unsigned int)type) {
1073 mutex_exit(&kernel_mutex);
1085 srv_conc_slot_t* conc_slot;
1091 kernel_mutex_temp =
static_cast<ib_mutex_t *
>(mem_alloc(
sizeof(
mutex_t)));
1092 mutex_create(kernel_mutex_key, &kernel_mutex, SYNC_KERNEL);
1094 commit_id_mutex_temp =
static_cast<ib_mutex_t *
>(mem_alloc(
sizeof(
mutex_t)));
1095 mutex_create(commit_id_mutex_key, &commit_id_mutex, SYNC_COMMIT_ID_LOCK);
1097 mutex_create(srv_innodb_monitor_mutex_key,
1098 &srv_innodb_monitor_mutex, SYNC_NO_ORDER_CHECK);
1102 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1110 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1111 slot = srv_mysql_table + i;
1125 srv_n_threads_active[i] = 0;
1126 srv_n_threads[i] = 0;
1129 srv_meter_low_water[i] = 50;
1130 srv_meter_high_water[i] = 100;
1131 srv_meter_high_water2[i] = 200;
1132 srv_meter_foreground[i] = 250;
1148 srv_conc_slots =
static_cast<srv_conc_slot_t *
>(mem_alloc(OS_THREAD_MAX_N *
sizeof(srv_conc_slot_t)));
1150 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1151 conc_slot = srv_conc_slots + i;
1170 srv_conc_slots = NULL;
1177 kernel_mutex_temp = NULL;
1179 srv_mysql_table = NULL;
1182 commit_id_mutex_temp = NULL;
1206UNIV_INTERN ulong srv_max_purge_lag = 0;
1218 ibool has_slept = FALSE;
1219 srv_conc_slot_t* slot = NULL;
1226 < (lint)srv_thread_concurrency,
1227 srv_replication_delay * 1000);
1235 if (trx->n_tickets_to_enter_innodb > 0) {
1236 trx->n_tickets_to_enter_innodb--;
1243 if (trx->declared_to_be_inside_innodb) {
1245 fputs(
" InnoDB: Error: trying to declare trx"
1246 " to enter InnoDB, but\n"
1247 "InnoDB: it already is declared.\n", stderr);
1255 ut_ad(srv_conc_n_threads >= 0);
1257 if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
1259 srv_conc_n_threads++;
1260 trx->declared_to_be_inside_innodb = TRUE;
1261 trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
1271 if (!has_slept && !trx->has_search_latch
1277 srv_conc_n_waiting_threads++;
1281 trx->
op_info =
"sleeping before joining InnoDB queue";
1288 if (SRV_THREAD_SLEEP_DELAY > 0) {
1296 srv_conc_n_waiting_threads--;
1303 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1304 slot = srv_conc_slots + i;
1312 if (i == OS_THREAD_MAX_N) {
1316 srv_conc_n_threads++;
1317 trx->declared_to_be_inside_innodb = TRUE;
1318 trx->n_tickets_to_enter_innodb = 0;
1326 if (trx->has_search_latch) {
1338 srv_conc_n_waiting_threads++;
1345 trx->
op_info =
"waiting in InnoDB queue";
1347 os_event_wait(slot->
event);
1353 srv_conc_n_waiting_threads--;
1362 trx->declared_to_be_inside_innodb = TRUE;
1363 trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
1378 if (UNIV_LIKELY(!srv_thread_concurrency)) {
1383 ut_ad(srv_conc_n_threads >= 0);
1387 srv_conc_n_threads++;
1388 trx->declared_to_be_inside_innodb = TRUE;
1389 trx->n_tickets_to_enter_innodb = 1;
1404 srv_conc_slot_t* slot = NULL;
1412 if (trx->declared_to_be_inside_innodb == FALSE) {
1419 ut_ad(srv_conc_n_threads > 0);
1420 srv_conc_n_threads--;
1421 trx->declared_to_be_inside_innodb = FALSE;
1422 trx->n_tickets_to_enter_innodb = 0;
1424 if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
1440 srv_conc_n_threads++;
1460 if (trx->n_tickets_to_enter_innodb > 0) {
1481srv_normalize_init_values(
void)
1487 n = srv_n_data_files;
1489 for (i = 0; i < n; i++) {
1490 srv_data_file_sizes[i] = srv_data_file_sizes[i]
1491 * ((1024 * 1024) / UNIV_PAGE_SIZE);
1494 srv_last_file_size_max = srv_last_file_size_max
1495 * ((1024 * 1024) / UNIV_PAGE_SIZE);
1497 srv_log_file_size = srv_log_file_size / UNIV_PAGE_SIZE;
1499 srv_log_buffer_size = srv_log_buffer_size / UNIV_PAGE_SIZE;
1519 err = srv_normalize_init_values();
1521 if (err != DB_SUCCESS) {
1543srv_table_reserve_slot_for_mysql(
void)
1549 ut_ad(mutex_own(&kernel_mutex));
1552 slot = srv_mysql_table + i;
1557 if (UNIV_UNLIKELY(i >= OS_THREAD_MAX_N)) {
1562 " InnoDB: There appear to be %lu MySQL"
1563 " threads currently waiting\n"
1564 "InnoDB: inside InnoDB, which is the"
1565 " upper limit. Cannot continue operation.\n"
1566 "InnoDB: We intentionally generate"
1567 " a seg fault to print a stack trace\n"
1568 "InnoDB: on Linux. But first we print"
1569 " a list of waiting threads.\n", (ulong) i);
1571 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1573 slot = srv_mysql_table + i;
1576 "Slot %lu: thread id %lu, type %lu,"
1577 " in use %lu, susp %lu, time %lu\n",
1590 slot = srv_mysql_table + i;
1619 ulint had_dict_lock;
1620 ibool was_declared_inside_innodb = FALSE;
1621 ib_int64_t start_time = 0;
1622 ib_int64_t finish_time;
1626 ulong lock_wait_timeout;
1628 ut_ad(!mutex_own(&kernel_mutex));
1634 mutex_enter(&kernel_mutex);
1638 if (thr->state == QUE_THR_RUNNING) {
1640 ut_ad(thr->is_active == TRUE);
1645 if (trx->was_chosen_as_deadlock_victim) {
1648 trx->was_chosen_as_deadlock_victim = FALSE;
1651 mutex_exit(&kernel_mutex);
1656 ut_ad(thr->is_active == FALSE);
1658 slot = srv_table_reserve_slot_for_mysql();
1660 event = slot->
event;
1668 if (thr->lock_state == QUE_THR_LOCK_ROW) {
1669 srv_n_lock_wait_count++;
1670 srv_n_lock_wait_current_count++;
1675 start_time = (ib_int64_t) sec * 1000000 + ms;
1682 mutex_exit(&kernel_mutex);
1684 if (trx->declared_to_be_inside_innodb) {
1686 was_declared_inside_innodb = TRUE;
1697 switch (had_dict_lock) {
1710 fputs(
" InnoDB: Error: dict X latch held in "
1711 "srv_suspend_mysql_thread\n", stderr);
1724 os_event_wait(event);
1729 switch (had_dict_lock) {
1731 row_mysql_freeze_data_dictionary(trx);
1737 row_mysql_lock_data_dictionary(trx);
1741 if (was_declared_inside_innodb) {
1748 mutex_enter(&kernel_mutex);
1756 if (thr->lock_state == QUE_THR_LOCK_ROW) {
1760 finish_time = (ib_int64_t) sec * 1000000 + ms;
1763 diff_time = (ulint) (finish_time - start_time);
1765 srv_n_lock_wait_current_count--;
1766 srv_n_lock_wait_time = srv_n_lock_wait_time + diff_time;
1767 if (diff_time > srv_n_lock_max_wait_time &&
1770 start_time != -1 && finish_time != -1) {
1771 srv_n_lock_max_wait_time = diff_time;
1778 if (trx->was_chosen_as_deadlock_victim) {
1781 trx->was_chosen_as_deadlock_victim = FALSE;
1784 mutex_exit(&kernel_mutex);
1792 if (lock_wait_timeout < 100000000
1793 && wait_time > (
double) lock_wait_timeout) {
1817 ut_ad(mutex_own(&kernel_mutex));
1819 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1821 slot = srv_mysql_table + i;
1839srv_refresh_innodb_monitor_stats(
void)
1842 mutex_enter(&srv_innodb_monitor_mutex);
1844 srv_last_monitor_time = time(NULL);
1848 btr_cur_n_sea_old = btr_cur_n_sea;
1849 btr_cur_n_non_sea_old = btr_cur_n_non_sea;
1855 srv_n_rows_inserted_old = srv_n_rows_inserted;
1856 srv_n_rows_updated_old = srv_n_rows_updated;
1857 srv_n_rows_deleted_old = srv_n_rows_deleted;
1858 srv_n_rows_read_old = srv_n_rows_read;
1860 mutex_exit(&srv_innodb_monitor_mutex);
1878 double time_elapsed;
1879 time_t current_time;
1883 mutex_enter(&srv_innodb_monitor_mutex);
1885 current_time = time(NULL);
1891 time_elapsed = difftime(current_time, srv_last_monitor_time)
1894 srv_last_monitor_time = time(NULL);
1896 fputs(
"\n=====================================\n", file);
1900 " INNODB MONITOR OUTPUT\n"
1901 "=====================================\n"
1902 "Per second averages calculated from the last %lu seconds\n",
1903 (ulong)time_elapsed);
1905 fputs(
"-----------------\n"
1906 "BACKGROUND THREAD\n"
1907 "-----------------\n", file);
1908 srv_print_master_thread_info(file);
1910 fputs(
"----------\n"
1912 "----------\n", file);
1920 mutex_enter(&dict_foreign_err_mutex);
1922 if (ftell(dict_foreign_err_file) != 0L) {
1923 fputs(
"------------------------\n"
1924 "LATEST FOREIGN KEY ERROR\n"
1925 "------------------------\n", file);
1929 mutex_exit(&dict_foreign_err_mutex);
1938 long t = ftell(file);
1947 long t = ftell(file);
1949 *trx_end = ULINT_UNDEFINED;
1951 *trx_end = (ulint) t;
1958 "--------\n", file);
1961 fputs(
"-------------------------------------\n"
1962 "INSERT BUFFER AND ADAPTIVE HASH INDEX\n"
1963 "-------------------------------------\n", file);
1966 ha_print_info(file, btr_search_sys->hash_index);
1969 "%.2f hash searches/s, %.2f non-hash searches/s\n",
1970 (btr_cur_n_sea - btr_cur_n_sea_old)
1972 (btr_cur_n_non_sea - btr_cur_n_non_sea_old)
1974 btr_cur_n_sea_old = btr_cur_n_sea;
1975 btr_cur_n_non_sea_old = btr_cur_n_non_sea;
1982 fputs(
"----------------------\n"
1983 "BUFFER POOL AND MEMORY\n"
1984 "----------------------\n", file);
1986 "Total memory allocated " ULINTPF
1987 "; in additional pool allocated " ULINTPF
"\n",
1990 fprintf(file,
"Dictionary memory allocated " ULINTPF
"\n",
1995 fputs(
"--------------\n"
1997 "--------------\n", file);
1998 fprintf(file,
"%ld queries inside InnoDB, %lu queries in queue\n",
1999 (
long) srv_conc_n_threads,
2000 (ulong) srv_conc_n_waiting_threads);
2002 fprintf(file,
"%lu read views open inside InnoDB\n",
2005 n_reserved = fil_space_get_n_reserved_extents(0);
2006 if (n_reserved > 0) {
2008 "%lu tablespace extents now reserved for"
2009 " B-tree split operations\n",
2010 (ulong) n_reserved);
2014 fprintf(file,
"Main thread process no. %lu, id %lu, state: %s\n",
2015 (ulong) srv_main_thread_process_no,
2016 (ulong) srv_main_thread_id,
2017 srv_main_thread_op_info);
2019 fprintf(file,
"Main thread id %lu, state: %s\n",
2020 (ulong) srv_main_thread_id,
2021 srv_main_thread_op_info);
2024 "Number of rows inserted " ULINTPF
2025 ", updated " ULINTPF
", deleted " ULINTPF
2026 ", read " ULINTPF
"\n",
2027 srv_n_rows_inserted,
2032 "%.2f inserts/s, %.2f updates/s,"
2033 " %.2f deletes/s, %.2f reads/s\n",
2034 (srv_n_rows_inserted - srv_n_rows_inserted_old)
2036 (srv_n_rows_updated - srv_n_rows_updated_old)
2038 (srv_n_rows_deleted - srv_n_rows_deleted_old)
2040 (srv_n_rows_read - srv_n_rows_read_old)
2043 srv_n_rows_inserted_old = srv_n_rows_inserted;
2044 srv_n_rows_updated_old = srv_n_rows_updated;
2045 srv_n_rows_deleted_old = srv_n_rows_deleted;
2046 srv_n_rows_read_old = srv_n_rows_read;
2048 fputs(
"----------------------------\n"
2049 "END OF INNODB MONITOR OUTPUT\n"
2050 "============================\n", file);
2051 mutex_exit(&srv_innodb_monitor_mutex);
2067 ulint flush_list_len;
2069 buf_get_total_stat(&stat);
2070 buf_get_total_list_len(&LRU_len, &free_len, &flush_list_len);
2072 mutex_enter(&srv_innodb_monitor_mutex);
2079 = fil_n_pending_log_flushes
2080 + fil_n_pending_tablespace_flushes;
2084 export_vars.innodb_data_writes = os_n_file_writes;
2085 export_vars.innodb_data_written = srv_data_written;
2088 = srv_buf_pool_write_requests;
2089 export_vars.innodb_buffer_pool_wait_free = srv_buf_pool_wait_free;
2090 export_vars.innodb_buffer_pool_pages_flushed = srv_buf_pool_flushed;
2096 export_vars.innodb_buffer_pool_pages_data = LRU_len;
2097 export_vars.innodb_buffer_pool_pages_dirty = flush_list_len;
2098 export_vars.innodb_buffer_pool_pages_free = free_len;
2101 = buf_get_latched_pages_number();
2107#ifdef HAVE_ATOMIC_BUILTINS
2114 export_vars.innodb_os_log_written = srv_os_log_written;
2115 export_vars.innodb_os_log_fsyncs = fil_n_log_flushes;
2116 export_vars.innodb_os_log_pending_fsyncs = fil_n_pending_log_flushes;
2117 export_vars.innodb_os_log_pending_writes = srv_os_log_pending_writes;
2118 export_vars.innodb_log_write_requests = srv_log_write_requests;
2120 export_vars.innodb_dblwr_pages_written = srv_dblwr_pages_written;
2121 export_vars.innodb_dblwr_writes = srv_dblwr_writes;
2125 export_vars.innodb_row_lock_waits = srv_n_lock_wait_count;
2127 = srv_n_lock_wait_current_count;
2128 export_vars.innodb_row_lock_time = srv_n_lock_wait_time / 1000;
2129 if (srv_n_lock_wait_count > 0) {
2131 (srv_n_lock_wait_time / 1000 / srv_n_lock_wait_count);
2136 = srv_n_lock_max_wait_time / 1000;
2138 export_vars.innodb_rows_inserted = srv_n_rows_inserted;
2139 export_vars.innodb_rows_updated = srv_n_rows_updated;
2140 export_vars.innodb_rows_deleted = srv_n_rows_deleted;
2141 export_vars.innodb_truncated_status_writes = srv_truncated_status_writes;
2143 mutex_exit(&srv_innodb_monitor_mutex);
2157 ib_int64_t sig_count;
2158 double time_elapsed;
2159 time_t current_time;
2160 time_t last_table_monitor_time;
2161 time_t last_tablespace_monitor_time;
2162 time_t last_monitor_time;
2163 ulint mutex_skipped;
2164 ibool last_srv_print_monitor;
2166#ifdef UNIV_DEBUG_THREAD_CREATION
2167 fprintf(stderr,
"Lock timeout thread starts, id %lu\n",
2171#ifdef UNIV_PFS_THREAD
2172 pfs_register_thread(srv_monitor_thread_key);
2175 srv_last_monitor_time =
ut_time();
2176 last_table_monitor_time =
ut_time();
2177 last_tablespace_monitor_time =
ut_time();
2178 last_monitor_time =
ut_time();
2180 last_srv_print_monitor = srv_print_innodb_monitor;
2182 srv_monitor_active = TRUE;
2193 time_elapsed = difftime(current_time, last_monitor_time);
2195 if (time_elapsed > 15) {
2196 last_monitor_time =
ut_time();
2198 if (srv_print_innodb_monitor) {
2204 if (!last_srv_print_monitor) {
2206 last_srv_print_monitor = TRUE;
2210 MUTEX_NOWAIT(mutex_skipped),
2218 last_srv_print_monitor = FALSE;
2222 if (srv_innodb_status) {
2223 mutex_enter(&srv_monitor_file_mutex);
2224 rewind(srv_monitor_file);
2226 MUTEX_NOWAIT(mutex_skipped),
2234 mutex_exit(&srv_monitor_file_mutex);
2237 if (srv_print_innodb_tablespace_monitor
2238 && difftime(current_time,
2239 last_tablespace_monitor_time) > 60) {
2240 last_tablespace_monitor_time =
ut_time();
2242 fputs(
"========================"
2243 "========================\n",
2248 fputs(
" INNODB TABLESPACE MONITOR OUTPUT\n"
2249 "========================"
2250 "========================\n",
2254 fputs(
"Validating tablespace\n", stderr);
2256 fputs(
"Validation ok\n"
2257 "---------------------------------------\n"
2258 "END OF INNODB TABLESPACE MONITOR OUTPUT\n"
2259 "=======================================\n",
2263 if (srv_print_innodb_table_monitor
2264 && difftime(current_time, last_table_monitor_time) > 60) {
2266 last_table_monitor_time =
ut_time();
2268 fputs(
"===========================================\n",
2273 fputs(
" INNODB TABLE MONITOR OUTPUT\n"
2274 "===========================================\n",
2278 fputs(
"-----------------------------------\n"
2279 "END OF INNODB TABLE MONITOR OUTPUT\n"
2280 "==================================\n",
2289 if (srv_print_innodb_monitor
2290 || srv_print_innodb_lock_monitor
2291 || srv_print_innodb_tablespace_monitor
2292 || srv_print_innodb_table_monitor) {
2296 srv_monitor_active = FALSE;
2301 srv_monitor_active = FALSE;
2308 OS_THREAD_DUMMY_RETURN;
2326 ib_int64_t sig_count;
2328#ifdef UNIV_PFS_THREAD
2329 pfs_register_thread(srv_lock_timeout_thread_key);
2341 srv_lock_timeout_active = TRUE;
2343 mutex_enter(&kernel_mutex);
2350 for (i = 0; i < OS_THREAD_MAX_N; i++) {
2352 slot = srv_mysql_table + i;
2356 ulong lock_wait_timeout;
2367 || (lock_wait_timeout < 100000000
2368 && (wait_time > (
double) lock_wait_timeout
2369 || wait_time < 0))) {
2388 mutex_exit(&kernel_mutex);
2398 srv_lock_timeout_active = FALSE;
2403 os_event_wait(srv_lock_timeout_thread_event);
2408 srv_lock_timeout_active = FALSE;
2415 OS_THREAD_DUMMY_RETURN;
2431 ulint fatal_cnt = 0;
2432 ib_uint64_t old_lsn;
2433 ib_uint64_t new_lsn;
2434 ib_int64_t sig_count;
2439 const void* sema = NULL;
2440 const void* old_sema = NULL;
2444#ifdef UNIV_DEBUG_THREAD_CREATION
2445 fprintf(stderr,
"Error monitor thread starts, id %lu\n",
2449#ifdef UNIV_PFS_THREAD
2450 pfs_register_thread(srv_error_monitor_thread_key);
2454 srv_error_monitor_active = TRUE;
2461 if (new_lsn < old_lsn) {
2462 drizzled::errmsg_printf(drizzled::error::INFO,
2463 "InnoDB: Error: old log sequence number %" PRIu64
" was greater than the new log sequence number %" PRIu64
"!"
2464 "InnoDB: Please submit a bug report to http://bugs.launchpad.net/drizzle",
2470 if (difftime(time(NULL), srv_last_monitor_time) > 60) {
2474 srv_refresh_innodb_monitor_stats();
2482 buf_flush_stat_update();
2491 && sema == old_sema &&
os_thread_eq(waiter, old_waiter)) {
2493 if (fatal_cnt > 10) {
2496 "InnoDB: Error: semaphore wait has lasted"
2498 "InnoDB: We intentionally crash the server,"
2499 " because it appears to be hung.\n",
2500 (ulong) srv_fatal_semaphore_wait_threshold);
2506 old_waiter = waiter;
2524 srv_error_monitor_active = FALSE;
2531 OS_THREAD_DUMMY_RETURN;
2547 time_t last_dump_time;
2548 time_t time_elapsed;
2550#ifdef UNIV_DEBUG_THREAD_CREATION
2551 fprintf(stderr,
"The LRU dump/restore thread has started, id %lu\n",
2558 last_dump_time = time(NULL);
2567 time_elapsed = time(NULL) - last_dump_time;
2569 if (auto_lru_dump > 0 && (time_t) auto_lru_dump < time_elapsed) {
2570 last_dump_time = time(NULL);
2581 OS_THREAD_DUMMY_RETURN;
2595 mutex_enter(&kernel_mutex);
2598 if (srv_n_threads_active[i] != 0) {
2604 mutex_exit(&kernel_mutex);
2620 srv_activity_count++;
2624 mutex_enter(&kernel_mutex);
2628 mutex_exit(&kernel_mutex);
2643 ut_ad(!mutex_own(&kernel_mutex));
2645 if (srv_n_purge_threads > 0
2648 mutex_enter(&kernel_mutex);
2652 mutex_exit(&kernel_mutex);
2663 srv_activity_count++;
2665 mutex_enter(&kernel_mutex);
2669 mutex_exit(&kernel_mutex);
2679 ut_ad(!mutex_own(&kernel_mutex));
2681 if (srv_n_purge_threads > 0) {
2683 mutex_enter(&kernel_mutex);
2687 mutex_exit(&kernel_mutex);
2698srv_sync_log_buffer_in_background(
void)
2701 time_t current_time = time(NULL);
2703 srv_main_thread_op_info =
"flushing log";
2704 if (difftime(current_time, srv_last_log_flush_time) >= 1) {
2706 srv_last_log_flush_time = current_time;
2707 srv_log_writes_and_flush++;
2716srv_master_do_purge(
void)
2719 ulint n_pages_purged = 0;
2721 ut_ad(!mutex_own(&kernel_mutex));
2723 ut_a(srv_n_purge_threads == 0);
2731 n_pages_purged =
trx_purge(srv_purge_batch_size);
2734 srv_sync_log_buffer_in_background();
2736 }
while (n_pages_purged > 0);
2752 ulint old_activity_count;
2753 ulint n_pages_purged = 0;
2754 ulint n_bytes_merged;
2755 ulint n_pages_flushed;
2756 uint32_t n_pages_flushed_prev = 0;
2757 ulint n_bytes_archived;
2758 ulint n_tables_to_drop;
2761 ulint n_ios_very_old;
2763 ulint next_itr_time;
2764 uint32_t prev_adaptive_flushing_method = ULINT32_UNDEFINED;
2765 uint32_t inner_loop = 0;
2766 bool skip_sleep =
false;
2769 struct t_prev_flush_info_struct {
2773 uint64_t oldest_modification;
2777 uint64_t oldest_lsn;
2779#ifdef UNIV_DEBUG_THREAD_CREATION
2780 fprintf(stderr,
"Master thread starts, id %lu\n",
2784#ifdef UNIV_PFS_THREAD
2785 pfs_register_thread(srv_master_thread_key);
2791 mutex_enter(&kernel_mutex);
2797 mutex_exit(&kernel_mutex);
2799 mutex_enter(&(log_sys->mutex));
2800 lsn_old = log_sys->lsn;
2801 mutex_exit(&(log_sys->mutex));
2807 srv_main_thread_op_info =
"reserving kernel mutex";
2809 buf_get_total_stat(&buf_stat);
2810 n_ios_very_old = log_sys->n_log_ios + buf_stat.
n_pages_read
2812 mutex_enter(&kernel_mutex);
2815 old_activity_count = srv_activity_count;
2817 mutex_exit(&kernel_mutex);
2821 goto suspend_thread;
2827 srv_last_log_flush_time = time(NULL);
2834 for (i = 0; i < 10; i++) {
2837 n_pages_flushed = 0;
2843 srv_main_thread_op_info =
"doing background drop tables";
2847 srv_main_thread_op_info =
"";
2851 goto background_loop;
2854 buf_get_total_stat(&buf_stat);
2859 srv_main_thread_op_info =
"sleeping";
2860 srv_main_1_second_loops++;
2862 if (skip_sleep ==
false) {
2863 if (next_itr_time > cur_time
2870 (next_itr_time - cur_time)
2897 srv_sync_log_buffer_in_background();
2899 srv_main_thread_op_info =
"making checkpoint";
2906 buf_get_total_stat(&buf_stat);
2908 + log_sys->n_pending_writes;
2911 if (n_pend_ios < SRV_PEND_IO_THRESHOLD
2912 && (n_ios - n_ios_old < SRV_RECENT_IO_ACTIVITY)) {
2913 srv_main_thread_op_info =
"doing insert buffer merge";
2914 ibuf_contract_for_n_pages(FALSE, PCT_IBUF_IO(5));
2917 srv_sync_log_buffer_in_background();
2921 > srv_max_buf_pool_modified_pct)) {
2926 srv_main_thread_op_info =
2927 "flushing buffer pool pages";
2928 n_pages_flushed = buf_flush_list(
2929 PCT_IO(100), IB_ULONGLONG_MAX);
2931 mutex_enter(&(log_sys->mutex));
2932 lsn_old = log_sys->lsn;
2933 mutex_exit(&(log_sys->mutex));
2934 prev_adaptive_flushing_method = ULINT32_UNDEFINED;
2935 }
else if (srv_adaptive_flushing
2936 && srv_adaptive_flushing_method == 0) {
2941 ulint n_flush = buf_flush_get_desired_flush_rate();
2944 srv_main_thread_op_info =
2945 "flushing buffer pool pages";
2946 n_flush =
ut_min(PCT_IO(100), n_flush);
2953 mutex_enter(&(log_sys->mutex));
2954 lsn_old = log_sys->lsn;
2955 mutex_exit(&(log_sys->mutex));
2956 prev_adaptive_flushing_method = ULINT32_UNDEFINED;
2957 }
else if (srv_adaptive_flushing
2958 && srv_adaptive_flushing_method == 1) {
2963 mutex_enter(&(log_sys->mutex));
2966 if (oldest_lsn == 0) {
2967 lsn_old = log_sys->lsn;
2968 mutex_exit(&(log_sys->mutex));
2971 if ((log_sys->lsn - oldest_lsn)
2972 > (log_sys->max_checkpoint_age)
2973 - ((log_sys->max_checkpoint_age) / 8)) {
2976 lsn_old = log_sys->lsn;
2977 mutex_exit(&(log_sys->mutex));
2978 }
else if ((log_sys->lsn - oldest_lsn)
2979 > (log_sys->max_checkpoint_age)/4) {
2982 uint64_t lsn = log_sys->lsn;
2984 uint64_t level, bpl;
2988 mutex_exit(&(log_sys->mutex));
2994 uint32_t n_blocks = 0;
3003 while (bpage != NULL) {
3005 if (oldest_modification != 0) {
3006 level += log_sys->max_checkpoint_age
3007 - (lsn - oldest_modification);
3014 bpl += ((ib_uint64_t) n_blocks * n_blocks
3015 * (lsn - lsn_old)) / level;
3020 if (!srv_use_doublewrite_buf) {
3022 bpl = (bpl * 7) / 8;
3027 n_pages_flushed = buf_flush_list(bpl,
3028 oldest_lsn + (lsn - lsn_old));
3029 if (n_pages_flushed == ULINT32_UNDEFINED) {
3031 goto retry_flush_batch;
3044 lsn_old = log_sys->lsn;
3045 mutex_exit(&(log_sys->mutex));
3048 prev_adaptive_flushing_method = 1;
3049 }
else if (srv_adaptive_flushing && srv_adaptive_flushing_method == 2) {
3055 mutex_enter(&(log_sys->mutex));
3058 mutex_exit(&(log_sys->mutex));
3061 next_itr_time -= 900;
3063 if (inner_loop < 10) {
3069 if (prev_adaptive_flushing_method == 2) {
3071 int32_t blocks_sum = 0;
3072 uint32_t flushed_blocks_sum = 0;
3076 int32_t blocks_num, new_blocks_num, flushed_blocks_num;
3085 while (bpage != NULL) {
3086 if (prev_flush_info[j].space == bpage->
space
3087 && prev_flush_info[j].offset == bpage->
offset
3088 && prev_flush_info[j].oldest_modification
3097 new_blocks_num = blocks_num;
3099 flushed_blocks_num = new_blocks_num
3100 + prev_flush_info[j].count
3102 if (flushed_blocks_num < 0) {
3103 flushed_blocks_num = 0;
3110 prev_flush_info[j].space = bpage->
space;
3111 prev_flush_info[j].offset = bpage->
offset;
3114 prev_flush_info[j].space = 0;
3115 prev_flush_info[j].offset = 0;
3116 prev_flush_info[j].oldest_modification = 0;
3119 flushed_blocks_sum += flushed_blocks_num;
3120 blocks_sum += blocks_num;
3123 n_flush = blocks_sum * (lsn - lsn_old) / log_sys->max_modified_age_async;
3124 if (flushed_blocks_sum > n_pages_flushed_prev) {
3125 n_flush -= (flushed_blocks_sum - n_pages_flushed_prev);
3130 n_pages_flushed = buf_flush_list(n_flush, oldest_lsn + (lsn - lsn_old));
3132 n_pages_flushed = 0;
3143 prev_flush_info[j].space = bpage->
space;
3144 prev_flush_info[j].offset = bpage->
offset;
3147 prev_flush_info[j].space = 0;
3148 prev_flush_info[j].offset = 0;
3149 prev_flush_info[j].oldest_modification = 0;
3152 n_pages_flushed = 0;
3156 prev_adaptive_flushing_method = 2;
3158 mutex_enter(&(log_sys->mutex));
3159 lsn_old = log_sys->lsn;
3160 mutex_exit(&(log_sys->mutex));
3161 prev_adaptive_flushing_method = ULINT32_UNDEFINED;
3164 if (n_pages_flushed == ULINT_UNDEFINED) {
3165 n_pages_flushed_prev = 0;
3167 n_pages_flushed_prev = n_pages_flushed;
3170 if (srv_activity_count == old_activity_count) {
3175 goto background_loop;
3182#ifdef MEM_PERIODIC_CHECK
3185 mem_validate_all_blocks();
3196 buf_get_total_stat(&buf_stat);
3201 srv_main_10_second_loops++;
3202 if (n_pend_ios < SRV_PEND_IO_THRESHOLD
3203 && (n_ios - n_ios_very_old < SRV_PAST_IO_ACTIVITY)) {
3205 srv_main_thread_op_info =
"flushing buffer pool pages";
3206 buf_flush_list(PCT_IO(100), IB_ULONGLONG_MAX);
3209 srv_sync_log_buffer_in_background();
3215 srv_main_thread_op_info =
"doing insert buffer merge";
3216 ibuf_contract_for_n_pages(FALSE, PCT_IBUF_IO(5));
3219 srv_sync_log_buffer_in_background();
3221 if (srv_n_purge_threads == 0) {
3222 srv_main_thread_op_info =
"master purging";
3224 srv_master_do_purge();
3228 goto background_loop;
3232 srv_main_thread_op_info =
"flushing buffer pool pages";
3242 n_pages_flushed = buf_flush_list(
3243 PCT_IO(100), IB_ULONGLONG_MAX);
3249 n_pages_flushed = buf_flush_list(
3250 PCT_IO(10), IB_ULONGLONG_MAX);
3253 srv_main_thread_op_info =
"making checkpoint";
3259 srv_main_thread_op_info =
"reserving kernel mutex";
3261 mutex_enter(&kernel_mutex);
3266 if (srv_activity_count != old_activity_count) {
3267 mutex_exit(&kernel_mutex);
3271 mutex_exit(&kernel_mutex);
3283 srv_main_background_loops++;
3284 srv_main_thread_op_info =
"doing background drop tables";
3288 if (n_tables_to_drop > 0) {
3299 if (srv_n_purge_threads == 0) {
3300 srv_main_thread_op_info =
"master purging";
3302 srv_master_do_purge();
3305 srv_main_thread_op_info =
"reserving kernel mutex";
3307 mutex_enter(&kernel_mutex);
3308 if (srv_activity_count != old_activity_count) {
3309 mutex_exit(&kernel_mutex);
3312 mutex_exit(&kernel_mutex);
3314 srv_main_thread_op_info =
"doing insert buffer merge";
3323 n_bytes_merged = ibuf_contract_for_n_pages(FALSE,
3327 srv_main_thread_op_info =
"reserving kernel mutex";
3329 mutex_enter(&kernel_mutex);
3330 if (srv_activity_count != old_activity_count) {
3331 mutex_exit(&kernel_mutex);
3334 mutex_exit(&kernel_mutex);
3337 srv_main_thread_op_info =
"flushing buffer pool pages";
3338 srv_main_flush_loops++;
3339 if (srv_fast_shutdown < 2) {
3340 n_pages_flushed = buf_flush_list(
3341 PCT_IO(100), IB_ULONGLONG_MAX);
3346 n_pages_flushed = 0;
3349 srv_main_thread_op_info =
"reserving kernel mutex";
3351 mutex_enter(&kernel_mutex);
3352 if (srv_activity_count != old_activity_count) {
3353 mutex_exit(&kernel_mutex);
3356 mutex_exit(&kernel_mutex);
3358 srv_main_thread_op_info =
"waiting for buffer pool flush to end";
3362 srv_sync_log_buffer_in_background();
3364 srv_main_thread_op_info =
"making checkpoint";
3376 srv_main_thread_op_info =
"reserving kernel mutex";
3378 mutex_enter(&kernel_mutex);
3379 if (srv_activity_count != old_activity_count) {
3380 mutex_exit(&kernel_mutex);
3383 mutex_exit(&kernel_mutex);
3389 n_bytes_archived = 0;
3394 if (n_tables_to_drop + n_pages_flushed
3395 + n_bytes_archived != 0) {
3404 goto background_loop;
3406 }
else if (n_tables_to_drop
3407 + n_pages_purged + n_bytes_merged + n_pages_flushed
3408 + n_bytes_archived != 0) {
3412 goto background_loop;
3419 srv_main_thread_op_info =
"suspending";
3421 mutex_enter(&kernel_mutex);
3424 mutex_exit(&kernel_mutex);
3429 srv_suspend_thread(slot);
3431 mutex_exit(&kernel_mutex);
3437 srv_main_thread_op_info =
"waiting for server activity";
3439 os_event_wait(slot->
event);
3454 OS_THREAD_DUMMY_RETURN;
3469 ulint n_total_purged = ULINT_UNDEFINED;
3470 ulint next_itr_time;
3472 ut_a(srv_n_purge_threads == 1);
3474#ifdef UNIV_DEBUG_THREAD_CREATION
3475 fprintf(stderr,
"InnoDB: Purge thread running, id %lu\n",
3479 mutex_enter(&kernel_mutex);
3485 mutex_exit(&kernel_mutex);
3491 ulint n_pages_purged;
3499 if (
trx_sys->rseg_history_len < srv_purge_batch_size
3500 || (n_total_purged == 0
3501 && retries >= TRX_SYS_N_RSEGS)) {
3503 mutex_enter(&kernel_mutex);
3505 srv_suspend_thread(slot);
3507 mutex_exit(&kernel_mutex);
3509 os_event_wait(slot->
event);
3517 || srv_fast_shutdown) {
3522 if (n_total_purged == 0 && retries <= TRX_SYS_N_RSEGS) {
3524 }
else if (n_total_purged > 0) {
3532 n_pages_purged =
trx_purge(srv_purge_batch_size);
3534 n_total_purged += n_pages_purged;
3536 }
while (n_pages_purged > 0 && !srv_fast_shutdown);
3538 srv_sync_log_buffer_in_background();
3541 if (next_itr_time > cur_time) {
3543 (next_itr_time - cur_time)
3547 next_itr_time = cur_time + 1000;
3551 mutex_enter(&kernel_mutex);
3554 srv_suspend_thread(slot);
3558 mutex_exit(&kernel_mutex);
3560#ifdef UNIV_DEBUG_THREAD_CREATION
3561 fprintf(stderr,
"InnoDB: Purge thread exiting, id %lu\n",
3569 OS_THREAD_DUMMY_RETURN;
3583 mutex_enter(&kernel_mutex);
3589 mutex_exit(&kernel_mutex);
UNIV_INTERN ib_uint64_t buf_pool_get_oldest_modification(void)
UNIV_INTERN void buf_refresh_io_stats_all(void)
UNIV_INLINE buf_pool_t * buf_pool_from_array(ulint index)
UNIV_INTERN ulint buf_get_modified_ratio_pct(void)
UNIV_INLINE ulint buf_pool_get_n_pages(void)
UNIV_INTERN ulint buf_get_n_pending_ios(void)
UNIV_INTERN bool buf_LRU_file_restore(void)
UNIV_INTERN void buf_LRU_stat_update(void)
UNIV_INTERN bool buf_LRU_file_dump(void)
struct buf_pool_stat_struct buf_pool_stat_t
struct buf_pool_struct buf_pool_t
struct buf_page_struct buf_page_t
UNIV_INTERN void dict_ind_init(void)
UNIV_INTERN void dict_print(void)
#define DICT_TF_FORMAT_MAX
UNIV_INTERN void thd_set_lock_wait_time(drizzled::Session *in_session, ulint value)
UNIV_INTERN ulong thd_lock_wait_timeout(drizzled::Session *)
UNIV_INTERN ibool trx_is_interrupted(trx_t *trx)
UNIV_INTERN ibool thd_is_replication_slave_thread(drizzled::Session *)
UNIV_INTERN void lock_cancel_waiting_and_release(lock_t *lock)
UNIV_INTERN void lock_print_info_all_transactions(FILE *file)
UNIV_INTERN ibool lock_print_info_summary(FILE *file, ibool nowait)
UNIV_INTERN void log_refresh_stats(void)
UNIV_INLINE void log_free_check(void)
UNIV_INTERN void log_print(FILE *file)
UNIV_INTERN void log_buffer_sync_in_background(ibool flush)
UNIV_INLINE ib_uint64_t log_get_lsn(void)
UNIV_INTERN ibool log_checkpoint(ibool sync, ibool write_always)
UNIV_INTERN void recv_sys_var_init(void)
UNIV_INTERN void mem_init(ulint size)
UNIV_INTERN ulint mem_pool_get_reserved(mem_pool_t *pool)
mem_pool_t * mem_comm_pool
UNIV_INTERN void os_aio_print(FILE *file)
ulint os_n_pending_writes
UNIV_INTERN ibool os_file_set_eof(FILE *file)
UNIV_INTERN void os_aio_refresh_stats(void)
UNIV_INTERN ulint os_proc_get_number(void)
UNIV_INTERN ib_int64_t os_event_reset(os_event_t event)
UNIV_INTERN void os_fast_mutex_free(os_fast_mutex_t *fast_mutex)
UNIV_INTERN ulint os_event_wait_time_low(os_event_t event, ulint time_in_usec, ib_int64_t reset_sig_count)
UNIV_INTERN os_event_t os_event_create(const char *name)
UNIV_INTERN void os_fast_mutex_lock(os_fast_mutex_t *fast_mutex)
UNIV_INTERN void os_event_set(os_event_t event)
UNIV_INTERN void os_fast_mutex_init(os_fast_mutex_t *fast_mutex)
os_event_struct_t * os_event_t
UNIV_INTERN void os_sync_init(void)
UNIV_INTERN void os_fast_mutex_unlock(os_fast_mutex_t *fast_mutex)
pthread_mutex_t os_fast_mutex_t
os_thread_t os_thread_id_t
UNIV_INTERN void os_thread_exit(void *exit_value)
UNIV_INTERN ibool os_thread_eq(os_thread_id_t a, os_thread_id_t b)
UNIV_INTERN void os_thread_sleep(ulint tm)
UNIV_INTERN os_thread_t os_thread_get_curr(void)
UNIV_INTERN os_thread_id_t os_thread_get_curr_id(void)
UNIV_INTERN ulint os_thread_pf(os_thread_id_t a)
UNIV_INLINE trx_t * thr_get_trx(que_thr_t *thr)
UNIV_INTERN void row_mysql_unfreeze_data_dictionary(trx_t *trx)
UNIV_INTERN ulint row_get_background_drop_list_len_low(void)
UNIV_INTERN void row_mysql_unlock_data_dictionary(trx_t *trx)
UNIV_INTERN ulint row_drop_tables_for_mysql_in_background(void)
UNIV_INTERN void srv_free(void)
UNIV_INTERN os_thread_ret_t srv_LRU_dump_restore_thread(void *arg)
UNIV_INTERN os_thread_ret_t srv_monitor_thread(void *arg)
UNIV_INTERN void srv_general_init(void)
UNIV_INTERN void srv_active_wake_master_thread(void)
ibool srv_locks_unsafe_for_binlog
@ SRV_FORCE_NO_BACKGROUND
UNIV_INTERN os_thread_ret_t srv_master_thread(void *arg)
UNIV_INTERN os_thread_ret_t srv_error_monitor_thread(void *arg)
const byte * srv_latin1_ordering
UNIV_INTERN ulint srv_release_threads(enum srv_thread_type type, ulint n)
UNIV_INTERN void srv_conc_force_enter_innodb(trx_t *trx)
ulint srv_buf_pool_instances
struct srv_sys_struct srv_sys_t
UNIV_INTERN os_thread_ret_t srv_lock_timeout_thread(void *arg)
UNIV_INTERN void srv_release_mysql_thread_if_suspended(que_thr_t *thr)
my_bool srv_file_per_table
UNIV_INTERN void srv_conc_exit_innodb(trx_t *trx)
UNIV_INTERN void srv_set_io_thread_op_info(ulint i, const char *str)
UNIV_INTERN void srv_que_task_enqueue_low(que_thr_t *thr)
UNIV_INTERN os_thread_ret_t srv_purge_thread(void *)
UNIV_INTERN ulint srv_thread_has_reserved_slot(enum srv_thread_type type)
uint32_t srv_auto_lru_dump
UNIV_INTERN ulint srv_get_n_threads(void)
UNIV_INTERN void srv_export_innodb_status(void)
UNIV_INTERN ibool srv_is_any_background_thread_active(void)
ulint srv_buf_pool_old_size
UNIV_INTERN ulint srv_boot(void)
UNIV_INTERN void srv_conc_force_exit_innodb(trx_t *trx)
UNIV_INTERN void srv_conc_enter_innodb(trx_t *trx)
ulint srv_max_file_format_at_startup
UNIV_INTERN void srv_wake_purge_thread_if_not_active(void)
UNIV_INTERN void srv_wake_master_thread(void)
UNIV_INTERN ibool srv_printf_innodb_monitor(FILE *file, ibool nowait, ulint *trx_start, ulint *trx_end)
UNIV_INTERN void srv_wake_purge_thread(void)
ulint srv_buf_pool_curr_size
struct export_var_struct export_struc
UNIV_INTERN void srv_suspend_mysql_thread(que_thr_t *thr)
UNIV_INTERN void srv_init(void)
struct srv_slot_struct srv_slot_t
@ SRV_SHUTDOWN_EXIT_THREADS
ib_uint64_t srv_start_lsn
ib_uint64_t oldest_modification
UT_LIST_NODE_T(srv_conc_slot_t) srv_conc_queue
drizzled::Session * mysql_thd
ulint dict_operation_lock_mode
UNIV_INTERN ibool sync_array_print_long_waits(os_thread_id_t *waiter, const void **sema) __attribute__((nonnull))
UNIV_INTERN void sync_arr_wake_threads_if_sema_free(void)
UNIV_INTERN void sync_print(FILE *file)
UNIV_INTERN void sync_init(void)
trx_i_s_cache_t * trx_i_s_cache
UNIV_INTERN void trx_i_s_cache_free(trx_i_s_cache_t *cache)
UNIV_INTERN void trx_i_s_cache_init(trx_i_s_cache_t *cache)
UNIV_INTERN ulint trx_purge(ulint limit)
UNIV_INTERN ibool trx_start(trx_t *trx, ulint rseg_id)
UNIV_INTERN void trx_search_latch_release_if_reserved(trx_t *trx)
UNIV_INTERN void trx_print(FILE *f, trx_t *trx, ulint max_query_len)
#define UT_LIST_GET_LEN(BASE)
#define UT_LIST_REMOVE(NAME, BASE, N)
#define UT_LIST_GET_FIRST(BASE)
#define UT_LIST_ADD_LAST(NAME, BASE, N)
#define UT_LIST_GET_NEXT(NAME, N)
#define UT_LIST_INIT(BASE)
#define UT_LIST_BASE_NODE_T(TYPE)
UNIV_INTERN void ut_mem_init(void)
ulint ut_total_allocated_memory
UNIV_INTERN ulint ut_time_ms(void)
UNIV_INTERN ib_time_t ut_time(void)
UNIV_INLINE ulint ut_min(ulint n1, ulint n2)
UNIV_INTERN int ut_usectime(ulint *sec, ulint *ms)
UNIV_INTERN void ut_print_timestamp(FILE *file)
UNIV_INTERN void ut_copy_file(FILE *dest, FILE *src)
#define UT_WAIT_FOR(cond, max_wait_us)
UNIV_INTERN double ut_difftime(ib_time_t time2, ib_time_t time1)