63 #include <drizzled/error.h>
64 #include <drizzled/errmsg_print.h>
93 UNIV_INTERN ibool srv_lower_case_table_names = FALSE;
97 UNIV_INTERN ulint srv_activity_count = 0;
100 UNIV_INTERN ulint srv_fatal_semaphore_wait_threshold = 600;
104 UNIV_INTERN ulint srv_dml_needed_delay = 0;
106 UNIV_INTERN ibool srv_lock_timeout_active = FALSE;
107 UNIV_INTERN ibool srv_monitor_active = FALSE;
108 UNIV_INTERN ibool srv_error_monitor_active = FALSE;
110 UNIV_INTERN
const char* srv_main_thread_op_info =
"";
117 UNIV_INTERN
char* srv_data_home = NULL;
118 #ifdef UNIV_LOG_ARCHIVE
119 UNIV_INTERN
char* srv_arch_dir = NULL;
132 #if DICT_TF_FORMAT_51
133 # error "DICT_TF_FORMAT_51 must be 0!"
143 UNIV_INTERN my_bool srv_use_native_aio = TRUE;
157 UNIV_INTERN ibool srv_use_native_conditions = FALSE;
160 UNIV_INTERN ulint srv_n_data_files = 0;
161 UNIV_INTERN
char** srv_data_file_names = NULL;
163 UNIV_INTERN ulint* srv_data_file_sizes = NULL;
166 UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE;
169 UNIV_INTERN ulint srv_last_file_size_max = 0;
172 UNIV_INTERN
unsigned int srv_auto_extend_increment = 8;
173 UNIV_INTERN ulint* srv_data_file_is_raw_partition = NULL;
178 UNIV_INTERN ibool srv_created_new_raw = FALSE;
180 UNIV_INTERN
char** srv_log_group_home_dirs = NULL;
182 UNIV_INTERN ulint srv_n_log_groups = ULINT_MAX;
183 UNIV_INTERN ulint srv_n_log_files = ULINT_MAX;
185 UNIV_INTERN ulint srv_log_file_size = ULINT_MAX;
187 UNIV_INTERN ulint srv_log_buffer_size = ULINT_MAX;
188 UNIV_INTERN ulong srv_flush_log_at_trx_commit = 1;
192 UNIV_INTERN
bool srv_adaptive_flushing = TRUE;
196 #define MAX_MUTEX_NOWAIT 20
202 #define MUTEX_NOWAIT(mutex_skipped) ((mutex_skipped) < MAX_MUTEX_NOWAIT)
206 #if defined(BUILD_DRIZZLE)
211 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
212 , 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
213 , 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
214 , 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F
215 , 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27
216 , 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F
217 , 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37
218 , 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F
219 , 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47
220 , 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F
221 , 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57
222 , 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F
223 , 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47
224 , 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F
225 , 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57
226 , 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F
227 , 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87
228 , 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F
229 , 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97
230 , 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F
231 , 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7
232 , 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF
233 , 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7
234 , 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF
235 , 0x41, 0x41, 0x41, 0x41, 0x5C, 0x5B, 0x5C, 0x43
236 , 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49
237 , 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x5D, 0xD7
238 , 0xD8, 0x55, 0x55, 0x55, 0x59, 0x59, 0xDE, 0xDF
239 , 0x41, 0x41, 0x41, 0x41, 0x5C, 0x5B, 0x5C, 0x43
240 , 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49
241 , 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x5D, 0xF7
242 , 0xD8, 0x55, 0x55, 0x55, 0x59, 0x59, 0xDE, 0xFF
250 UNIV_INTERN my_bool srv_use_sys_malloc = TRUE;
260 UNIV_INTERN ulint srv_mem_pool_size = ULINT_MAX;
261 UNIV_INTERN ulint srv_lock_table_size = ULINT_MAX;
265 UNIV_INTERN ulint srv_n_file_io_threads = ULINT_MAX;
266 UNIV_INTERN ulint srv_n_read_io_threads = ULINT_MAX;
267 UNIV_INTERN ulint srv_n_write_io_threads = ULINT_MAX;
270 UNIV_INTERN ulint srv_page_size_shift = 0;
271 UNIV_INTERN ulint srv_page_size = 0;
274 UNIV_INTERN uint32_t srv_log_block_size = 0;
279 UNIV_INTERN ulong srv_read_ahead_threshold = 56;
281 #ifdef UNIV_LOG_ARCHIVE
282 UNIV_INTERN ibool srv_log_archive_on = FALSE;
283 UNIV_INTERN ibool srv_archive_recovery = 0;
284 UNIV_INTERN ib_uint64_t srv_archive_recovery_limit_lsn;
295 UNIV_INTERN ulong srv_insert_buffer_batch_size = 20;
297 UNIV_INTERN
char* srv_file_flush_method_str = NULL;
301 UNIV_INTERN ulint srv_max_n_open_files = 300;
304 UNIV_INTERN ulong srv_io_capacity = 200;
311 UNIV_INTERN ulong srv_max_buf_pool_modified_pct = 75;
314 UNIV_INTERN ulong srv_n_purge_threads = 0;
317 UNIV_INTERN ulong srv_purge_batch_size = 20;
320 UNIV_INTERN ulint srv_data_read = 0;
323 UNIV_INTERN ulint srv_data_written = 0;
326 UNIV_INTERN ulint srv_log_write_requests = 0;
329 UNIV_INTERN ulint srv_log_writes = 0;
332 UNIV_INTERN ulint srv_os_log_written = 0;
335 UNIV_INTERN ulint srv_os_log_pending_writes = 0;
339 UNIV_INTERN ulint srv_log_waits = 0;
343 UNIV_INTERN ulint srv_dblwr_writes = 0;
347 UNIV_INTERN ulint srv_dblwr_pages_written = 0;
350 UNIV_INTERN ulint srv_buf_pool_write_requests = 0;
355 UNIV_INTERN ulint srv_buf_pool_wait_free = 0;
359 UNIV_INTERN ulint srv_buf_pool_flushed = 0;
374 UNIV_INTERN ulint srv_force_recovery = 0;
380 UNIV_INTERN ulint srv_max_n_threads = 0;
390 UNIV_INTERN ulong srv_thread_concurrency = 0;
398 UNIV_INTERN lint srv_conc_n_threads = 0;
401 UNIV_INTERN ulint srv_conc_n_waiting_threads = 0;
425 #define SRV_FREE_TICKETS_TO_ENTER srv_n_free_tickets_to_enter
426 #define SRV_THREAD_SLEEP_DELAY srv_thread_sleep_delay
432 UNIV_INTERN ulint srv_fast_shutdown = 0;
435 UNIV_INTERN ibool srv_innodb_status = FALSE;
439 UNIV_INTERN ib_uint64_t srv_stats_sample_pages = 8;
441 UNIV_INTERN ibool srv_use_doublewrite_buf = TRUE;
442 UNIV_INTERN ibool srv_use_checksums = TRUE;
444 UNIV_INTERN ulong srv_replication_delay = 0;
446 UNIV_INTERN uint64_t srv_ibuf_max_size = 0;
447 UNIV_INTERN uint32_t srv_ibuf_active_contract = 0;
448 UNIV_INTERN uint32_t srv_ibuf_accel_rate = 100;
450 #define PCT_IBUF_IO(pct) (srv_io_capacity * srv_ibuf_accel_rate \
453 UNIV_INTERN uint32_t srv_checkpoint_age_target = 0;
454 UNIV_INTERN uint32_t srv_flush_neighbor_pages = 1;
456 UNIV_INTERN uint32_t srv_read_ahead = 3;
457 UNIV_INTERN uint32_t srv_adaptive_flushing_method = 0;
461 UNIV_INTERN ibool srv_read_only = FALSE;
462 UNIV_INTERN ibool srv_fake_write = FALSE;
463 UNIV_INTERN ibool srv_apply_log_only = FALSE;
466 UNIV_INTERN ulong srv_n_spin_wait_rounds = 30;
467 UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500;
468 UNIV_INTERN ulong srv_thread_sleep_delay = 10000;
469 UNIV_INTERN ulong srv_spin_wait_delay = 6;
470 UNIV_INTERN ibool srv_priority_boost = TRUE;
473 UNIV_INTERN ibool srv_print_thread_releases = FALSE;
474 UNIV_INTERN ibool srv_print_lock_waits = FALSE;
475 UNIV_INTERN ibool srv_print_buf_io = FALSE;
476 UNIV_INTERN ibool srv_print_log_io = FALSE;
477 UNIV_INTERN ibool srv_print_latch_waits = FALSE;
480 UNIV_INTERN ulint srv_n_rows_inserted = 0;
481 UNIV_INTERN ulint srv_n_rows_updated = 0;
482 UNIV_INTERN ulint srv_n_rows_deleted = 0;
483 UNIV_INTERN ulint srv_n_rows_read = 0;
485 static ulint srv_n_rows_inserted_old = 0;
486 static ulint srv_n_rows_updated_old = 0;
487 static ulint srv_n_rows_deleted_old = 0;
488 static ulint srv_n_rows_read_old = 0;
490 UNIV_INTERN ulint srv_n_lock_wait_count = 0;
491 UNIV_INTERN ulint srv_n_lock_wait_current_count = 0;
492 UNIV_INTERN ib_int64_t srv_n_lock_wait_time = 0;
493 UNIV_INTERN ulint srv_n_lock_max_wait_time = 0;
495 UNIV_INTERN ulint srv_truncated_status_writes = 0;
501 UNIV_INTERN ibool srv_print_verbose_log = TRUE;
502 UNIV_INTERN ibool srv_print_innodb_monitor = FALSE;
503 UNIV_INTERN ibool srv_print_innodb_lock_monitor = FALSE;
504 UNIV_INTERN ibool srv_print_innodb_tablespace_monitor = FALSE;
505 UNIV_INTERN ibool srv_print_innodb_table_monitor = FALSE;
510 UNIV_INTERN
const char* srv_io_thread_op_info[SRV_MAX_N_IO_THREADS];
511 UNIV_INTERN
const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
513 UNIV_INTERN time_t srv_last_monitor_time;
515 UNIV_INTERN
mutex_t srv_innodb_monitor_mutex;
518 UNIV_INTERN
mutex_t srv_monitor_file_mutex;
520 #ifdef UNIV_PFS_MUTEX
522 UNIV_INTERN mysql_pfs_key_t kernel_mutex_key;
524 UNIV_INTERN mysql_pfs_key_t commit_id_mutex_key;
526 UNIV_INTERN mysql_pfs_key_t srv_innodb_monitor_mutex_key;
528 UNIV_INTERN mysql_pfs_key_t srv_monitor_file_mutex_key;
530 UNIV_INTERN mysql_pfs_key_t srv_dict_tmpfile_mutex_key;
532 UNIV_INTERN mysql_pfs_key_t srv_misc_tmpfile_mutex_key;
536 UNIV_INTERN FILE* srv_monitor_file;
540 UNIV_INTERN
mutex_t srv_dict_tmpfile_mutex;
542 UNIV_INTERN FILE* srv_dict_tmpfile;
546 UNIV_INTERN
mutex_t srv_misc_tmpfile_mutex;
548 UNIV_INTERN FILE* srv_misc_tmpfile;
550 UNIV_INTERN ulint srv_main_thread_process_no = 0;
551 UNIV_INTERN ulint srv_main_thread_id = 0;
556 static ulint srv_main_1_second_loops = 0;
558 static ulint srv_main_sleeps = 0;
560 static ulint srv_main_10_second_loops = 0;
562 static ulint srv_main_background_loops = 0;
564 static ulint srv_main_flush_loops = 0;
566 static ulint srv_log_writes_and_flush = 0;
572 static time_t srv_last_log_flush_time;
577 #define SRV_PEND_IO_THRESHOLD (PCT_IO(3))
578 #define SRV_RECENT_IO_ACTIVITY (PCT_IO(5))
579 #define SRV_PAST_IO_ACTIVITY (PCT_IO(200))
755 unsigned suspended:1;
766 UNIV_INTERN
srv_slot_t* srv_mysql_table = NULL;
774 UNIV_INTERN
os_event_t srv_lock_timeout_thread_event;
780 UNIV_INTERN byte srv_pad1[64];
782 UNIV_INTERN
mutex_t* kernel_mutex_temp;
784 UNIV_INTERN
mutex_t* commit_id_mutex_temp;
788 UNIV_INTERN byte srv_pad2[64];
798 static ulint srv_meter_low_water[
SRV_MASTER + 1];
799 static ulint srv_meter_high_water[
SRV_MASTER + 1];
800 static ulint srv_meter_high_water2[
SRV_MASTER + 1];
801 static ulint srv_meter_foreground[
SRV_MASTER + 1];
808 srv_print_master_thread_info(
812 fprintf(file,
"srv_master_thread loops: %lu 1_second, %lu sleeps, "
813 "%lu 10_second, %lu background, %lu flush\n",
814 srv_main_1_second_loops, srv_main_sleeps,
815 srv_main_10_second_loops, srv_main_background_loops,
816 srv_main_flush_loops);
817 fprintf(file,
"srv_master_thread log flush and writes: %lu\n",
818 srv_log_writes_and_flush);
825 UNIV_INTERN ulint srv_n_threads_active[
SRV_MASTER + 1];
826 UNIV_INTERN ulint srv_n_threads[
SRV_MASTER + 1];
838 ut_a(i < SRV_MAX_N_IO_THREADS);
840 srv_io_thread_op_info[i] = str;
849 srv_table_get_nth_slot(
853 ut_a(index < OS_THREAD_MAX_N);
869 mutex_enter(&kernel_mutex);
873 n_threads += srv_n_threads[i];
876 mutex_exit(&kernel_mutex);
888 srv_table_reserve_slot(
899 slot = srv_table_get_nth_slot(i);
903 slot = srv_table_get_nth_slot(i);
927 srv_suspend_thread(
void)
935 ut_ad(mutex_own(&kernel_mutex));
939 if (srv_print_thread_releases) {
941 "Suspending thread %lu to slot %lu\n",
945 slot = srv_table_get_nth_slot(slot_no);
956 ut_ad(srv_n_threads_active[type] > 0);
958 srv_n_threads_active[type]--;
984 ut_ad(mutex_own(&kernel_mutex));
986 for (i = 0; i < OS_THREAD_MAX_N; i++) {
988 slot = srv_table_get_nth_slot(i);
991 (static_cast<srv_thread_type>(slot->
type) == type) &&
996 srv_n_threads_active[type]++;
1000 if (srv_print_thread_releases) {
1002 "Releasing thread %lu type %lu"
1004 (ulong) slot->
id, (ulong) type,
1031 mutex_enter(&kernel_mutex);
1035 slot = srv_table_get_nth_slot(slot_no);
1042 mutex_exit(&kernel_mutex);
1060 kernel_mutex_temp =
static_cast<ib_mutex_t *
>(mem_alloc(
sizeof(
mutex_t)));
1061 mutex_create(kernel_mutex_key, &kernel_mutex, SYNC_KERNEL);
1063 commit_id_mutex_temp =
static_cast<ib_mutex_t *
>(mem_alloc(
sizeof(
mutex_t)));
1064 mutex_create(commit_id_mutex_key, &commit_id_mutex, SYNC_COMMIT_ID_LOCK);
1066 mutex_create(srv_innodb_monitor_mutex_key,
1067 &srv_innodb_monitor_mutex, SYNC_NO_ORDER_CHECK);
1071 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1072 slot = srv_table_get_nth_slot(i);
1081 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1082 slot = srv_mysql_table + i;
1098 srv_n_threads_active[i] = 0;
1099 srv_n_threads[i] = 0;
1102 srv_meter_low_water[i] = 50;
1103 srv_meter_high_water[i] = 100;
1104 srv_meter_high_water2[i] = 200;
1105 srv_meter_foreground[i] = 250;
1123 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1124 conc_slot = srv_conc_slots + i;
1143 srv_conc_slots = NULL;
1150 kernel_mutex_temp = NULL;
1152 srv_mysql_table = NULL;
1155 commit_id_mutex_temp = NULL;
1180 UNIV_INTERN ulong srv_max_purge_lag = 0;
1192 ibool has_slept = FALSE;
1200 < (lint)srv_thread_concurrency,
1201 srv_replication_delay * 1000);
1209 if (trx->n_tickets_to_enter_innodb > 0) {
1210 trx->n_tickets_to_enter_innodb--;
1217 if (trx->declared_to_be_inside_innodb) {
1219 fputs(
" InnoDB: Error: trying to declare trx"
1220 " to enter InnoDB, but\n"
1221 "InnoDB: it already is declared.\n", stderr);
1229 ut_ad(srv_conc_n_threads >= 0);
1231 if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
1233 srv_conc_n_threads++;
1234 trx->declared_to_be_inside_innodb = TRUE;
1235 trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
1245 if (!has_slept && !trx->has_search_latch
1251 srv_conc_n_waiting_threads++;
1255 trx->
op_info =
"sleeping before joining InnoDB queue";
1262 if (SRV_THREAD_SLEEP_DELAY > 0) {
1270 srv_conc_n_waiting_threads--;
1277 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1278 slot = srv_conc_slots + i;
1286 if (i == OS_THREAD_MAX_N) {
1290 srv_conc_n_threads++;
1291 trx->declared_to_be_inside_innodb = TRUE;
1292 trx->n_tickets_to_enter_innodb = 0;
1300 if (trx->has_search_latch) {
1312 srv_conc_n_waiting_threads++;
1319 trx->
op_info =
"waiting in InnoDB queue";
1321 os_event_wait(slot->
event);
1327 srv_conc_n_waiting_threads--;
1336 trx->declared_to_be_inside_innodb = TRUE;
1337 trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
1352 if (UNIV_LIKELY(!srv_thread_concurrency)) {
1357 ut_ad(srv_conc_n_threads >= 0);
1361 srv_conc_n_threads++;
1362 trx->declared_to_be_inside_innodb = TRUE;
1363 trx->n_tickets_to_enter_innodb = 1;
1386 if (trx->declared_to_be_inside_innodb == FALSE) {
1393 ut_ad(srv_conc_n_threads > 0);
1394 srv_conc_n_threads--;
1395 trx->declared_to_be_inside_innodb = FALSE;
1396 trx->n_tickets_to_enter_innodb = 0;
1398 if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
1414 srv_conc_n_threads++;
1434 if (trx->n_tickets_to_enter_innodb > 0) {
1455 srv_normalize_init_values(
void)
1461 n = srv_n_data_files;
1463 for (i = 0; i < n; i++) {
1464 srv_data_file_sizes[i] = srv_data_file_sizes[i]
1465 * ((1024 * 1024) / UNIV_PAGE_SIZE);
1468 srv_last_file_size_max = srv_last_file_size_max
1469 * ((1024 * 1024) / UNIV_PAGE_SIZE);
1471 srv_log_file_size = srv_log_file_size / UNIV_PAGE_SIZE;
1473 srv_log_buffer_size = srv_log_buffer_size / UNIV_PAGE_SIZE;
1493 err = srv_normalize_init_values();
1495 if (err != DB_SUCCESS) {
1517 srv_table_reserve_slot_for_mysql(
void)
1523 ut_ad(mutex_own(&kernel_mutex));
1526 slot = srv_mysql_table + i;
1531 if (i >= OS_THREAD_MAX_N) {
1536 " InnoDB: There appear to be %lu MySQL"
1537 " threads currently waiting\n"
1538 "InnoDB: inside InnoDB, which is the"
1539 " upper limit. Cannot continue operation.\n"
1540 "InnoDB: We intentionally generate"
1541 " a seg fault to print a stack trace\n"
1542 "InnoDB: on Linux. But first we print"
1543 " a list of waiting threads.\n", (ulong) i);
1545 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1547 slot = srv_mysql_table + i;
1550 "Slot %lu: thread id %lu, type %lu,"
1551 " in use %lu, susp %lu, time %lu\n",
1564 slot = srv_mysql_table + i;
1593 ulint had_dict_lock;
1594 ibool was_declared_inside_innodb = FALSE;
1595 ib_int64_t start_time = 0;
1596 ib_int64_t finish_time;
1600 ulong lock_wait_timeout;
1602 ut_ad(!mutex_own(&kernel_mutex));
1608 mutex_enter(&kernel_mutex);
1612 if (thr->
state == QUE_THR_RUNNING) {
1619 if (trx->was_chosen_as_deadlock_victim) {
1622 trx->was_chosen_as_deadlock_victim = FALSE;
1625 mutex_exit(&kernel_mutex);
1632 slot = srv_table_reserve_slot_for_mysql();
1634 event = slot->
event;
1643 srv_n_lock_wait_count++;
1644 srv_n_lock_wait_current_count++;
1649 start_time = (ib_int64_t) sec * 1000000 + ms;
1656 mutex_exit(&kernel_mutex);
1658 if (trx->declared_to_be_inside_innodb) {
1660 was_declared_inside_innodb = TRUE;
1671 switch (had_dict_lock) {
1684 fputs(
" InnoDB: Error: dict X latch held in "
1685 "srv_suspend_mysql_thread\n", stderr);
1698 os_event_wait(event);
1703 switch (had_dict_lock) {
1705 row_mysql_freeze_data_dictionary(trx);
1711 row_mysql_lock_data_dictionary(trx);
1715 if (was_declared_inside_innodb) {
1722 mutex_enter(&kernel_mutex);
1734 finish_time = (ib_int64_t) sec * 1000000 + ms;
1737 diff_time = (ulint) (finish_time - start_time);
1739 srv_n_lock_wait_current_count--;
1740 srv_n_lock_wait_time = srv_n_lock_wait_time + diff_time;
1741 if (diff_time > srv_n_lock_max_wait_time &&
1744 start_time != -1 && finish_time != -1) {
1745 srv_n_lock_max_wait_time = diff_time;
1752 if (trx->was_chosen_as_deadlock_victim) {
1755 trx->was_chosen_as_deadlock_victim = FALSE;
1758 mutex_exit(&kernel_mutex);
1766 if (lock_wait_timeout < 100000000
1767 && wait_time > (
double) lock_wait_timeout) {
1791 ut_ad(mutex_own(&kernel_mutex));
1793 for (i = 0; i < OS_THREAD_MAX_N; i++) {
1795 slot = srv_mysql_table + i;
1813 srv_refresh_innodb_monitor_stats(
void)
1816 mutex_enter(&srv_innodb_monitor_mutex);
1818 srv_last_monitor_time = time(NULL);
1822 btr_cur_n_sea_old = btr_cur_n_sea;
1823 btr_cur_n_non_sea_old = btr_cur_n_non_sea;
1827 buf_refresh_io_stats_all();
1829 srv_n_rows_inserted_old = srv_n_rows_inserted;
1830 srv_n_rows_updated_old = srv_n_rows_updated;
1831 srv_n_rows_deleted_old = srv_n_rows_deleted;
1832 srv_n_rows_read_old = srv_n_rows_read;
1834 mutex_exit(&srv_innodb_monitor_mutex);
1852 double time_elapsed;
1853 time_t current_time;
1857 mutex_enter(&srv_innodb_monitor_mutex);
1859 current_time = time(NULL);
1865 time_elapsed = difftime(current_time, srv_last_monitor_time)
1868 srv_last_monitor_time = time(NULL);
1870 fputs(
"\n=====================================\n", file);
1874 " INNODB MONITOR OUTPUT\n"
1875 "=====================================\n"
1876 "Per second averages calculated from the last %lu seconds\n",
1877 (ulong)time_elapsed);
1879 fputs(
"-----------------\n"
1880 "BACKGROUND THREAD\n"
1881 "-----------------\n", file);
1882 srv_print_master_thread_info(file);
1884 fputs(
"----------\n"
1886 "----------\n", file);
1894 mutex_enter(&dict_foreign_err_mutex);
1896 if (ftell(dict_foreign_err_file) != 0L) {
1897 fputs(
"------------------------\n"
1898 "LATEST FOREIGN KEY ERROR\n"
1899 "------------------------\n", file);
1903 mutex_exit(&dict_foreign_err_mutex);
1912 long t = ftell(file);
1914 *trx_start = ULINT_UNDEFINED;
1916 *trx_start = (ulint) t;
1921 long t = ftell(file);
1923 *trx_end = ULINT_UNDEFINED;
1925 *trx_end = (ulint) t;
1932 "--------\n", file);
1935 fputs(
"-------------------------------------\n"
1936 "INSERT BUFFER AND ADAPTIVE HASH INDEX\n"
1937 "-------------------------------------\n", file);
1940 ha_print_info(file, btr_search_sys->
hash_index);
1943 "%.2f hash searches/s, %.2f non-hash searches/s\n",
1944 (btr_cur_n_sea - btr_cur_n_sea_old)
1946 (btr_cur_n_non_sea - btr_cur_n_non_sea_old)
1948 btr_cur_n_sea_old = btr_cur_n_sea;
1949 btr_cur_n_non_sea_old = btr_cur_n_non_sea;
1956 fputs(
"----------------------\n"
1957 "BUFFER POOL AND MEMORY\n"
1958 "----------------------\n", file);
1960 "Total memory allocated " ULINTPF
1961 "; in additional pool allocated " ULINTPF
"\n",
1964 fprintf(file,
"Dictionary memory allocated " ULINTPF
"\n",
1969 fputs(
"--------------\n"
1971 "--------------\n", file);
1972 fprintf(file,
"%ld queries inside InnoDB, %lu queries in queue\n",
1973 (
long) srv_conc_n_threads,
1974 (ulong) srv_conc_n_waiting_threads);
1976 fprintf(file,
"%lu read views open inside InnoDB\n",
1979 n_reserved = fil_space_get_n_reserved_extents(0);
1980 if (n_reserved > 0) {
1982 "%lu tablespace extents now reserved for"
1983 " B-tree split operations\n",
1984 (ulong) n_reserved);
1988 fprintf(file,
"Main thread process no. %lu, id %lu, state: %s\n",
1989 (ulong) srv_main_thread_process_no,
1990 (ulong) srv_main_thread_id,
1991 srv_main_thread_op_info);
1993 fprintf(file,
"Main thread id %lu, state: %s\n",
1994 (ulong) srv_main_thread_id,
1995 srv_main_thread_op_info);
1998 "Number of rows inserted " ULINTPF
1999 ", updated " ULINTPF
", deleted " ULINTPF
2000 ", read " ULINTPF
"\n",
2001 srv_n_rows_inserted,
2006 "%.2f inserts/s, %.2f updates/s,"
2007 " %.2f deletes/s, %.2f reads/s\n",
2008 (srv_n_rows_inserted - srv_n_rows_inserted_old)
2010 (srv_n_rows_updated - srv_n_rows_updated_old)
2012 (srv_n_rows_deleted - srv_n_rows_deleted_old)
2014 (srv_n_rows_read - srv_n_rows_read_old)
2017 srv_n_rows_inserted_old = srv_n_rows_inserted;
2018 srv_n_rows_updated_old = srv_n_rows_updated;
2019 srv_n_rows_deleted_old = srv_n_rows_deleted;
2020 srv_n_rows_read_old = srv_n_rows_read;
2022 fputs(
"----------------------------\n"
2023 "END OF INNODB MONITOR OUTPUT\n"
2024 "============================\n", file);
2025 mutex_exit(&srv_innodb_monitor_mutex);
2041 ulint flush_list_len;
2043 buf_get_total_stat(&stat);
2044 buf_get_total_list_len(&LRU_len, &free_len, &flush_list_len);
2046 mutex_enter(&srv_innodb_monitor_mutex);
2053 = fil_n_pending_log_flushes
2054 + fil_n_pending_tablespace_flushes;
2062 = srv_buf_pool_write_requests;
2075 = buf_get_latched_pages_number();
2081 #ifdef HAVE_ATOMIC_BUILTINS
2101 = srv_n_lock_wait_current_count;
2103 if (srv_n_lock_wait_count > 0) {
2105 (srv_n_lock_wait_time / 1000 / srv_n_lock_wait_count);
2110 = srv_n_lock_max_wait_time / 1000;
2117 mutex_exit(&srv_innodb_monitor_mutex);
2131 ib_int64_t sig_count;
2132 double time_elapsed;
2133 time_t current_time;
2134 time_t last_table_monitor_time;
2135 time_t last_tablespace_monitor_time;
2136 time_t last_monitor_time;
2137 ulint mutex_skipped;
2138 ibool last_srv_print_monitor;
2140 #ifdef UNIV_DEBUG_THREAD_CREATION
2141 fprintf(stderr,
"Lock timeout thread starts, id %lu\n",
2145 #ifdef UNIV_PFS_THREAD
2146 pfs_register_thread(srv_monitor_thread_key);
2149 srv_last_monitor_time =
ut_time();
2150 last_table_monitor_time =
ut_time();
2151 last_tablespace_monitor_time =
ut_time();
2152 last_monitor_time =
ut_time();
2154 last_srv_print_monitor = srv_print_innodb_monitor;
2156 srv_monitor_active = TRUE;
2167 time_elapsed = difftime(current_time, last_monitor_time);
2169 if (time_elapsed > 15) {
2170 last_monitor_time =
ut_time();
2172 if (srv_print_innodb_monitor) {
2178 if (!last_srv_print_monitor) {
2180 last_srv_print_monitor = TRUE;
2184 MUTEX_NOWAIT(mutex_skipped),
2192 last_srv_print_monitor = FALSE;
2196 if (srv_innodb_status) {
2197 mutex_enter(&srv_monitor_file_mutex);
2198 rewind(srv_monitor_file);
2200 MUTEX_NOWAIT(mutex_skipped),
2208 mutex_exit(&srv_monitor_file_mutex);
2211 if (srv_print_innodb_tablespace_monitor
2212 && difftime(current_time,
2213 last_tablespace_monitor_time) > 60) {
2214 last_tablespace_monitor_time =
ut_time();
2216 fputs(
"========================"
2217 "========================\n",
2222 fputs(
" INNODB TABLESPACE MONITOR OUTPUT\n"
2223 "========================"
2224 "========================\n",
2228 fputs(
"Validating tablespace\n", stderr);
2230 fputs(
"Validation ok\n"
2231 "---------------------------------------\n"
2232 "END OF INNODB TABLESPACE MONITOR OUTPUT\n"
2233 "=======================================\n",
2237 if (srv_print_innodb_table_monitor
2238 && difftime(current_time, last_table_monitor_time) > 60) {
2240 last_table_monitor_time =
ut_time();
2242 fputs(
"===========================================\n",
2247 fputs(
" INNODB TABLE MONITOR OUTPUT\n"
2248 "===========================================\n",
2252 fputs(
"-----------------------------------\n"
2253 "END OF INNODB TABLE MONITOR OUTPUT\n"
2254 "==================================\n",
2263 if (srv_print_innodb_monitor
2264 || srv_print_innodb_lock_monitor
2265 || srv_print_innodb_tablespace_monitor
2266 || srv_print_innodb_table_monitor) {
2270 srv_monitor_active = FALSE;
2275 srv_monitor_active = FALSE;
2282 OS_THREAD_DUMMY_RETURN;
2300 ib_int64_t sig_count;
2302 #ifdef UNIV_PFS_THREAD
2303 pfs_register_thread(srv_lock_timeout_thread_key);
2315 srv_lock_timeout_active = TRUE;
2317 mutex_enter(&kernel_mutex);
2324 for (i = 0; i < OS_THREAD_MAX_N; i++) {
2326 slot = srv_mysql_table + i;
2330 ulong lock_wait_timeout;
2341 || (lock_wait_timeout < 100000000
2342 && (wait_time > (
double) lock_wait_timeout
2343 || wait_time < 0))) {
2362 mutex_exit(&kernel_mutex);
2372 srv_lock_timeout_active = FALSE;
2377 os_event_wait(srv_lock_timeout_thread_event);
2382 srv_lock_timeout_active = FALSE;
2389 OS_THREAD_DUMMY_RETURN;
2405 ulint fatal_cnt = 0;
2406 ib_uint64_t old_lsn;
2407 ib_uint64_t new_lsn;
2408 ib_int64_t sig_count;
2412 #ifdef UNIV_DEBUG_THREAD_CREATION
2413 fprintf(stderr,
"Error monitor thread starts, id %lu\n",
2417 #ifdef UNIV_PFS_THREAD
2418 pfs_register_thread(srv_error_monitor_thread_key);
2422 srv_error_monitor_active = TRUE;
2429 if (new_lsn < old_lsn) {
2430 drizzled::errmsg_printf(drizzled::error::INFO,
2431 "InnoDB: Error: old log sequence number %"PRIu64
" was greater than the new log sequence number %"PRIu64
"!"
2432 "InnoDB: Please submit a bug report to http://bugs.launchpad.net/drizzle",
2438 if (difftime(time(NULL), srv_last_monitor_time) > 60) {
2442 srv_refresh_innodb_monitor_stats();
2447 buf_LRU_stat_update();
2450 buf_flush_stat_update();
2460 if (fatal_cnt > 10) {
2463 "InnoDB: Error: semaphore wait has lasted"
2465 "InnoDB: We intentionally crash the server,"
2466 " because it appears to be hung.\n",
2467 (ulong) srv_fatal_semaphore_wait_threshold);
2489 srv_error_monitor_active = FALSE;
2496 OS_THREAD_DUMMY_RETURN;
2512 time_t last_dump_time;
2513 time_t time_elapsed;
2515 #ifdef UNIV_DEBUG_THREAD_CREATION
2516 fprintf(stderr,
"The LRU dump/restore thread has started, id %lu\n",
2521 buf_LRU_file_restore();
2523 last_dump_time = time(NULL);
2532 time_elapsed = time(NULL) - last_dump_time;
2534 if (auto_lru_dump > 0 && (time_t) auto_lru_dump < time_elapsed) {
2535 last_dump_time = time(NULL);
2536 buf_LRU_file_dump();
2546 OS_THREAD_DUMMY_RETURN;
2560 mutex_enter(&kernel_mutex);
2563 if (srv_n_threads_active[i] != 0) {
2569 mutex_exit(&kernel_mutex);
2585 srv_activity_count++;
2589 mutex_enter(&kernel_mutex);
2593 mutex_exit(&kernel_mutex);
2608 ut_ad(!mutex_own(&kernel_mutex));
2610 if (srv_n_purge_threads > 0
2613 mutex_enter(&kernel_mutex);
2617 mutex_exit(&kernel_mutex);
2628 srv_activity_count++;
2630 mutex_enter(&kernel_mutex);
2634 mutex_exit(&kernel_mutex);
2644 ut_ad(!mutex_own(&kernel_mutex));
2646 if (srv_n_purge_threads > 0) {
2648 mutex_enter(&kernel_mutex);
2652 mutex_exit(&kernel_mutex);
2663 srv_sync_log_buffer_in_background(
void)
2666 time_t current_time = time(NULL);
2668 srv_main_thread_op_info =
"flushing log";
2669 if (difftime(current_time, srv_last_log_flush_time) >= 1) {
2671 srv_last_log_flush_time = current_time;
2672 srv_log_writes_and_flush++;
2681 srv_master_do_purge(
void)
2684 ulint n_pages_purged;
2686 ut_ad(!mutex_own(&kernel_mutex));
2688 ut_a(srv_n_purge_threads == 0);
2696 n_pages_purged =
trx_purge(srv_purge_batch_size);
2699 srv_sync_log_buffer_in_background();
2701 }
while (n_pages_purged > 0);
2717 ulint old_activity_count;
2718 ulint n_pages_purged = 0;
2719 ulint n_bytes_merged;
2720 ulint n_pages_flushed;
2721 uint32_t n_pages_flushed_prev = 0;
2722 ulint n_bytes_archived;
2723 ulint n_tables_to_drop;
2726 ulint n_ios_very_old;
2728 ulint next_itr_time;
2729 uint32_t prev_adaptive_flushing_method = ULINT32_UNDEFINED;
2730 uint32_t inner_loop = 0;
2731 bool skip_sleep =
false;
2734 struct t_prev_flush_info_struct {
2738 uint64_t oldest_modification;
2742 uint64_t oldest_lsn;
2744 #ifdef UNIV_DEBUG_THREAD_CREATION
2745 fprintf(stderr,
"Master thread starts, id %lu\n",
2749 #ifdef UNIV_PFS_THREAD
2750 pfs_register_thread(srv_master_thread_key);
2758 mutex_enter(&kernel_mutex);
2762 mutex_exit(&kernel_mutex);
2764 mutex_enter(&(log_sys->
mutex));
2765 lsn_old = log_sys->
lsn;
2766 mutex_exit(&(log_sys->
mutex));
2772 srv_main_thread_op_info =
"reserving kernel mutex";
2774 buf_get_total_stat(&buf_stat);
2777 mutex_enter(&kernel_mutex);
2780 old_activity_count = srv_activity_count;
2782 mutex_exit(&kernel_mutex);
2786 goto suspend_thread;
2792 srv_last_log_flush_time = time(NULL);
2799 for (i = 0; i < 10; i++) {
2802 n_pages_flushed = 0;
2808 srv_main_thread_op_info =
"doing background drop tables";
2812 srv_main_thread_op_info =
"";
2816 goto background_loop;
2819 buf_get_total_stat(&buf_stat);
2824 srv_main_thread_op_info =
"sleeping";
2825 srv_main_1_second_loops++;
2827 if (skip_sleep ==
false) {
2828 if (next_itr_time > cur_time
2835 (next_itr_time - cur_time)
2862 srv_sync_log_buffer_in_background();
2864 srv_main_thread_op_info =
"making checkpoint";
2871 buf_get_total_stat(&buf_stat);
2872 n_pend_ios = buf_get_n_pending_ios()
2876 if (n_pend_ios < SRV_PEND_IO_THRESHOLD
2877 && (n_ios - n_ios_old < SRV_RECENT_IO_ACTIVITY)) {
2878 srv_main_thread_op_info =
"doing insert buffer merge";
2879 ibuf_contract_for_n_pages(FALSE, PCT_IBUF_IO(5));
2882 srv_sync_log_buffer_in_background();
2885 if (UNIV_UNLIKELY(buf_get_modified_ratio_pct()
2886 > srv_max_buf_pool_modified_pct)) {
2891 srv_main_thread_op_info =
2892 "flushing buffer pool pages";
2893 n_pages_flushed = buf_flush_list(
2894 PCT_IO(100), IB_ULONGLONG_MAX);
2896 mutex_enter(&(log_sys->
mutex));
2897 lsn_old = log_sys->
lsn;
2898 mutex_exit(&(log_sys->
mutex));
2899 prev_adaptive_flushing_method = ULINT32_UNDEFINED;
2900 }
else if (srv_adaptive_flushing
2901 && srv_adaptive_flushing_method == 0) {
2906 ulint n_flush = buf_flush_get_desired_flush_rate();
2909 srv_main_thread_op_info =
2910 "flushing buffer pool pages";
2911 n_flush =
ut_min(PCT_IO(100), n_flush);
2918 mutex_enter(&(log_sys->
mutex));
2919 lsn_old = log_sys->
lsn;
2920 mutex_exit(&(log_sys->
mutex));
2921 prev_adaptive_flushing_method = ULINT32_UNDEFINED;
2922 }
else if (srv_adaptive_flushing
2923 && srv_adaptive_flushing_method == 1) {
2928 mutex_enter(&(log_sys->
mutex));
2930 oldest_lsn = buf_pool_get_oldest_modification();
2931 if (oldest_lsn == 0) {
2932 lsn_old = log_sys->
lsn;
2933 mutex_exit(&(log_sys->
mutex));
2936 if ((log_sys->
lsn - oldest_lsn)
2941 lsn_old = log_sys->
lsn;
2942 mutex_exit(&(log_sys->
mutex));
2943 }
else if ((log_sys->
lsn - oldest_lsn)
2947 uint64_t lsn = log_sys->
lsn;
2949 uint64_t level, bpl;
2953 mutex_exit(&(log_sys->
mutex));
2959 uint32_t n_blocks = 0;
2968 while (bpage != NULL) {
2970 if (oldest_modification != 0) {
2972 - (lsn - oldest_modification);
2979 bpl += ((ib_uint64_t) n_blocks * n_blocks
2980 * (lsn - lsn_old)) / level;
2985 if (!srv_use_doublewrite_buf) {
2987 bpl = (bpl * 7) / 8;
2992 n_pages_flushed = buf_flush_list(bpl,
2993 oldest_lsn + (lsn - lsn_old));
2994 if (n_pages_flushed == ULINT32_UNDEFINED) {
2996 goto retry_flush_batch;
3009 lsn_old = log_sys->
lsn;
3010 mutex_exit(&(log_sys->
mutex));
3013 prev_adaptive_flushing_method = 1;
3014 }
else if (srv_adaptive_flushing && srv_adaptive_flushing_method == 2) {
3020 mutex_enter(&(log_sys->
mutex));
3021 oldest_lsn = buf_pool_get_oldest_modification();
3023 mutex_exit(&(log_sys->
mutex));
3026 next_itr_time -= 900;
3028 if (inner_loop < 10) {
3034 if (prev_adaptive_flushing_method == 2) {
3036 int32_t blocks_sum = 0;
3037 uint32_t new_blocks_sum = 0;
3038 uint32_t flushed_blocks_sum = 0;
3042 int32_t blocks_num, new_blocks_num, flushed_blocks_num;
3051 while (bpage != NULL) {
3052 if (prev_flush_info[j].space == bpage->
space
3053 && prev_flush_info[j].offset == bpage->
offset
3054 && prev_flush_info[j].oldest_modification
3063 new_blocks_num = blocks_num;
3065 flushed_blocks_num = new_blocks_num
3066 + prev_flush_info[j].count
3068 if (flushed_blocks_num < 0) {
3069 flushed_blocks_num = 0;
3076 prev_flush_info[j].space = bpage->
space;
3077 prev_flush_info[j].offset = bpage->
offset;
3080 prev_flush_info[j].space = 0;
3081 prev_flush_info[j].offset = 0;
3082 prev_flush_info[j].oldest_modification = 0;
3085 new_blocks_sum += new_blocks_num;
3086 flushed_blocks_sum += flushed_blocks_num;
3087 blocks_sum += blocks_num;
3091 if (flushed_blocks_sum > n_pages_flushed_prev) {
3092 n_flush -= (flushed_blocks_sum - n_pages_flushed_prev);
3097 n_pages_flushed = buf_flush_list(n_flush, oldest_lsn + (lsn - lsn_old));
3099 n_pages_flushed = 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 n_pages_flushed = 0;
3123 prev_adaptive_flushing_method = 2;
3125 mutex_enter(&(log_sys->
mutex));
3126 lsn_old = log_sys->
lsn;
3127 mutex_exit(&(log_sys->
mutex));
3128 prev_adaptive_flushing_method = ULINT32_UNDEFINED;
3131 if (n_pages_flushed == ULINT_UNDEFINED) {
3132 n_pages_flushed_prev = 0;
3134 n_pages_flushed_prev = n_pages_flushed;
3137 if (srv_activity_count == old_activity_count) {
3142 goto background_loop;
3149 #ifdef MEM_PERIODIC_CHECK
3152 mem_validate_all_blocks();
3163 buf_get_total_stat(&buf_stat);
3168 srv_main_10_second_loops++;
3169 if (n_pend_ios < SRV_PEND_IO_THRESHOLD
3170 && (n_ios - n_ios_very_old < SRV_PAST_IO_ACTIVITY)) {
3172 srv_main_thread_op_info =
"flushing buffer pool pages";
3173 buf_flush_list(PCT_IO(100), IB_ULONGLONG_MAX);
3176 srv_sync_log_buffer_in_background();
3182 srv_main_thread_op_info =
"doing insert buffer merge";
3183 ibuf_contract_for_n_pages(FALSE, PCT_IBUF_IO(5));
3186 srv_sync_log_buffer_in_background();
3188 if (srv_n_purge_threads == 0) {
3189 srv_main_thread_op_info =
"master purging";
3191 srv_master_do_purge();
3195 goto background_loop;
3199 srv_main_thread_op_info =
"flushing buffer pool pages";
3203 if (buf_get_modified_ratio_pct() > 70) {
3209 n_pages_flushed = buf_flush_list(
3210 PCT_IO(100), IB_ULONGLONG_MAX);
3216 n_pages_flushed = buf_flush_list(
3217 PCT_IO(10), IB_ULONGLONG_MAX);
3220 srv_main_thread_op_info =
"making checkpoint";
3226 srv_main_thread_op_info =
"reserving kernel mutex";
3228 mutex_enter(&kernel_mutex);
3233 if (srv_activity_count != old_activity_count) {
3234 mutex_exit(&kernel_mutex);
3238 mutex_exit(&kernel_mutex);
3250 srv_main_background_loops++;
3251 srv_main_thread_op_info =
"doing background drop tables";
3255 if (n_tables_to_drop > 0) {
3266 if (srv_n_purge_threads == 0) {
3267 srv_main_thread_op_info =
"master purging";
3269 srv_master_do_purge();
3272 srv_main_thread_op_info =
"reserving kernel mutex";
3274 mutex_enter(&kernel_mutex);
3275 if (srv_activity_count != old_activity_count) {
3276 mutex_exit(&kernel_mutex);
3279 mutex_exit(&kernel_mutex);
3281 srv_main_thread_op_info =
"doing insert buffer merge";
3290 n_bytes_merged = ibuf_contract_for_n_pages(FALSE,
3294 srv_main_thread_op_info =
"reserving kernel mutex";
3296 mutex_enter(&kernel_mutex);
3297 if (srv_activity_count != old_activity_count) {
3298 mutex_exit(&kernel_mutex);
3301 mutex_exit(&kernel_mutex);
3304 srv_main_thread_op_info =
"flushing buffer pool pages";
3305 srv_main_flush_loops++;
3306 if (srv_fast_shutdown < 2) {
3307 n_pages_flushed = buf_flush_list(
3308 PCT_IO(100), IB_ULONGLONG_MAX);
3313 n_pages_flushed = 0;
3316 srv_main_thread_op_info =
"reserving kernel mutex";
3318 mutex_enter(&kernel_mutex);
3319 if (srv_activity_count != old_activity_count) {
3320 mutex_exit(&kernel_mutex);
3323 mutex_exit(&kernel_mutex);
3325 srv_main_thread_op_info =
"waiting for buffer pool flush to end";
3329 srv_sync_log_buffer_in_background();
3331 srv_main_thread_op_info =
"making checkpoint";
3335 if (buf_get_modified_ratio_pct() > srv_max_buf_pool_modified_pct) {
3343 srv_main_thread_op_info =
"reserving kernel mutex";
3345 mutex_enter(&kernel_mutex);
3346 if (srv_activity_count != old_activity_count) {
3347 mutex_exit(&kernel_mutex);
3350 mutex_exit(&kernel_mutex);
3356 n_bytes_archived = 0;
3361 if (n_tables_to_drop + n_pages_flushed
3362 + n_bytes_archived != 0) {
3371 goto background_loop;
3373 }
else if (n_tables_to_drop
3374 + n_pages_purged + n_bytes_merged + n_pages_flushed
3375 + n_bytes_archived != 0) {
3379 goto background_loop;
3386 srv_main_thread_op_info =
"suspending";
3388 mutex_enter(&kernel_mutex);
3391 mutex_exit(&kernel_mutex);
3396 event = srv_suspend_thread();
3398 mutex_exit(&kernel_mutex);
3404 srv_main_thread_op_info =
"waiting for server activity";
3406 os_event_wait(event);
3422 #if !defined(__SUNPRO_C)
3423 OS_THREAD_DUMMY_RETURN;
3438 ulint slot_no = ULINT_UNDEFINED;
3439 ulint n_total_purged = ULINT_UNDEFINED;
3440 ulint next_itr_time;
3442 ut_a(srv_n_purge_threads == 1);
3444 #ifdef UNIV_DEBUG_THREAD_CREATION
3445 fprintf(stderr,
"InnoDB: Purge thread running, id %lu\n",
3449 mutex_enter(&kernel_mutex);
3451 slot_no = srv_table_reserve_slot(
SRV_WORKER);
3453 slot = srv_table_get_nth_slot(slot_no);
3457 mutex_exit(&kernel_mutex);
3463 ulint n_pages_purged;
3472 || n_total_purged == 0) {
3476 mutex_enter(&kernel_mutex);
3478 event = srv_suspend_thread();
3480 mutex_exit(&kernel_mutex);
3482 os_event_wait(event);
3488 || srv_fast_shutdown) {
3498 n_pages_purged =
trx_purge(srv_purge_batch_size);
3500 n_total_purged += n_pages_purged;
3502 }
while (n_pages_purged > 0 && !srv_fast_shutdown);
3504 srv_sync_log_buffer_in_background();
3507 if (next_itr_time > cur_time) {
3509 (next_itr_time - cur_time)
3513 next_itr_time = cur_time + 1000;
3517 mutex_enter(&kernel_mutex);
3519 ut_ad(srv_table_get_nth_slot(slot_no) == slot);
3522 srv_suspend_thread();
3529 mutex_exit(&kernel_mutex);
3531 #ifdef UNIV_DEBUG_THREAD_CREATION
3532 fprintf(stderr,
"InnoDB: Purge thread exiting, id %lu\n",
3540 OS_THREAD_DUMMY_RETURN;
3554 mutex_enter(&kernel_mutex);
3560 mutex_exit(&kernel_mutex);