diff options
author | Mikael Ronstrom <mikael@dator8> | 2011-01-04 18:46:01 +0100 |
---|---|---|
committer | Mikael Ronstrom <mikael@dator8> | 2011-01-04 18:46:01 +0100 |
commit | 6e7752d557aa0d77e49299eefa04136fe45bbb11 (patch) | |
tree | 3099d3c6d9977c59627e466389081f2dae42b159 /storage/innobase/srv/srv0srv.c | |
parent | d0182e61a189fada37c19281c69fd4824e6092a8 (diff) | |
parent | ee46dc0f23e45104071b35ff18b9ea5a20a23a2a (diff) | |
download | mariadb-git-6e7752d557aa0d77e49299eefa04136fe45bbb11.tar.gz |
merge
Diffstat (limited to 'storage/innobase/srv/srv0srv.c')
-rw-r--r-- | storage/innobase/srv/srv0srv.c | 104 |
1 files changed, 74 insertions, 30 deletions
diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index f86f31ddfb0..14fe7e57859 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -424,6 +424,7 @@ UNIV_INTERN ulint srv_n_lock_wait_current_count = 0; UNIV_INTERN ib_int64_t srv_n_lock_wait_time = 0; UNIV_INTERN ulint srv_n_lock_max_wait_time = 0; +UNIV_INTERN ulint srv_truncated_status_writes = 0; /* Set the following to 0 if you want InnoDB to write messages on @@ -694,6 +695,12 @@ struct srv_slot_struct{ /* Table for MySQL threads where they will be suspended to wait for locks */ UNIV_INTERN srv_slot_t* srv_mysql_table = NULL; +UNIV_INTERN os_event_t srv_timeout_event; + +UNIV_INTERN os_event_t srv_monitor_event; + +UNIV_INTERN os_event_t srv_error_event; + UNIV_INTERN os_event_t srv_lock_timeout_thread_event; UNIV_INTERN srv_sys_t* srv_sys = NULL; @@ -1011,6 +1018,12 @@ srv_init(void) ut_a(slot->event); } + srv_error_event = os_event_create(NULL); + + srv_timeout_event = os_event_create(NULL); + + srv_monitor_event = os_event_create(NULL); + srv_lock_timeout_thread_event = os_event_create(NULL); for (i = 0; i < SRV_MASTER + 1; i++) { @@ -1592,6 +1605,18 @@ srv_suspend_mysql_thread( row_mysql_unfreeze_data_dictionary(trx); break; case RW_X_LATCH: + /* There should never be a lock wait when the + dictionary latch is reserved in X mode. Dictionary + transactions should only acquire locks on dictionary + tables, not other tables. All access to dictionary + tables should be covered by dictionary + transactions. */ + ut_print_timestamp(stderr); + fputs(" InnoDB: Error: dict X latch held in " + "srv_suspend_mysql_thread\n", stderr); + /* This should never occur. This incorrect handling + was added in the early development of + ha_innobase::add_index() in InnoDB Plugin 1.0. */ /* Release fast index creation latch */ row_mysql_unlock_data_dictionary(trx); break; @@ -1613,6 +1638,9 @@ srv_suspend_mysql_thread( row_mysql_freeze_data_dictionary(trx); break; case RW_X_LATCH: + /* This should never occur. This incorrect handling + was added in the early development of + ha_innobase::add_index() in InnoDB Plugin 1.0. */ row_mysql_lock_data_dictionary(trx); break; } @@ -2017,6 +2045,7 @@ srv_export_innodb_status(void) export_vars.innodb_rows_inserted = srv_n_rows_inserted; export_vars.innodb_rows_updated = srv_n_rows_updated; export_vars.innodb_rows_deleted = srv_n_rows_deleted; + export_vars.innodb_truncated_status_writes = srv_truncated_status_writes; mutex_exit(&srv_innodb_monitor_mutex); } @@ -2032,6 +2061,7 @@ srv_monitor_thread( /*!< in: a dummy parameter required by os_thread_create */ { + ib_int64_t sig_count; double time_elapsed; time_t current_time; time_t last_table_monitor_time; @@ -2050,26 +2080,28 @@ srv_monitor_thread( #endif UT_NOT_USED(arg); - srv_last_monitor_time = time(NULL); - last_table_monitor_time = time(NULL); - last_tablespace_monitor_time = time(NULL); - last_monitor_time = time(NULL); + srv_last_monitor_time = ut_time(); + last_table_monitor_time = ut_time(); + last_tablespace_monitor_time = ut_time(); + last_monitor_time = ut_time(); mutex_skipped = 0; last_srv_print_monitor = srv_print_innodb_monitor; loop: srv_monitor_active = TRUE; /* Wake up every 5 seconds to see if we need to print - monitor information. */ + monitor information or if signalled at shutdown. */ - os_thread_sleep(5000000); + sig_count = os_event_reset(srv_monitor_event); - current_time = time(NULL); + os_event_wait_time_low(srv_monitor_event, 5000000, sig_count); + + current_time = ut_time(); time_elapsed = difftime(current_time, last_monitor_time); if (time_elapsed > 15) { - last_monitor_time = time(NULL); + last_monitor_time = ut_time(); if (srv_print_innodb_monitor) { /* Reset mutex_skipped counter everytime @@ -2113,7 +2145,7 @@ loop: if (srv_print_innodb_tablespace_monitor && difftime(current_time, last_tablespace_monitor_time) > 60) { - last_tablespace_monitor_time = time(NULL); + last_tablespace_monitor_time = ut_time(); fputs("========================" "========================\n", @@ -2139,7 +2171,7 @@ loop: if (srv_print_innodb_table_monitor && difftime(current_time, last_table_monitor_time) > 60) { - last_table_monitor_time = time(NULL); + last_table_monitor_time = ut_time(); fputs("===========================================\n", stderr); @@ -2199,16 +2231,20 @@ srv_lock_timeout_thread( ibool some_waits; double wait_time; ulint i; + ib_int64_t sig_count; #ifdef UNIV_PFS_THREAD pfs_register_thread(srv_lock_timeout_thread_key); #endif loop: + /* When someone is waiting for a lock, we wake up every second and check if a timeout has passed for a lock wait */ - os_thread_sleep(1000000); + sig_count = os_event_reset(srv_timeout_event); + + os_event_wait_time_low(srv_timeout_event, 1000000, sig_count); srv_lock_timeout_active = TRUE; @@ -2303,6 +2339,7 @@ srv_error_monitor_thread( ulint fatal_cnt = 0; ib_uint64_t old_lsn; ib_uint64_t new_lsn; + ib_int64_t sig_count; old_lsn = srv_start_lsn; @@ -2378,7 +2415,9 @@ loop: fflush(stderr); - os_thread_sleep(1000000); + sig_count = os_event_reset(srv_error_event); + + os_event_wait_time_low(srv_error_event, 1000000, sig_count); if (srv_shutdown_state < SRV_SHUTDOWN_CLEANUP) { @@ -2622,11 +2661,28 @@ loop: when there is database activity */ srv_last_log_flush_time = time(NULL); - next_itr_time = ut_time_ms(); + + /* Sleep for 1 second on entrying the for loop below the first time. */ + next_itr_time = ut_time_ms() + 1000; for (i = 0; i < 10; i++) { ulint cur_time = ut_time_ms(); + /* ALTER TABLE in MySQL requires on Unix that the table handler + can drop tables lazily after there no longer are SELECT + queries to them. */ + + srv_main_thread_op_info = "doing background drop tables"; + + row_drop_tables_for_mysql_in_background(); + + srv_main_thread_op_info = ""; + + if (srv_fast_shutdown && srv_shutdown_state > 0) { + + goto background_loop; + } + buf_get_total_stat(&buf_stat); n_ios_old = log_sys->n_log_ios + buf_stat.n_pages_read @@ -2635,7 +2691,8 @@ loop: srv_main_thread_op_info = "sleeping"; srv_main_1_second_loops++; - if (next_itr_time > cur_time) { + if (next_itr_time > cur_time + && srv_shutdown_state == SRV_SHUTDOWN_NONE) { /* Get sleep interval in micro seconds. We use ut_min() to avoid long sleep in case of @@ -2649,21 +2706,6 @@ loop: /* Each iteration should happen at 1 second interval. */ next_itr_time = ut_time_ms() + 1000; - /* ALTER TABLE in MySQL requires on Unix that the table handler - can drop tables lazily after there no longer are SELECT - queries to them. */ - - srv_main_thread_op_info = "doing background drop tables"; - - row_drop_tables_for_mysql_in_background(); - - srv_main_thread_op_info = ""; - - if (srv_fast_shutdown && srv_shutdown_state > 0) { - - goto background_loop; - } - /* Flush logs if needed */ srv_sync_log_buffer_in_background(); @@ -2841,7 +2883,9 @@ background_loop: MySQL tries to drop a table while there are still open handles to it and we had to put it to the background drop queue.) */ - os_thread_sleep(100000); + if (srv_shutdown_state == SRV_SHUTDOWN_NONE) { + os_thread_sleep(100000); + } } if (srv_n_purge_threads == 0) { |