Commit d8ef4994 authored by inaam's avatar inaam

Forward port r1520 from branches/5.0

Patch to allow monitor threads to stop before proceeding with normal shutdown. 
Also have a separate time counter for tablespace monitor.

reviewed by: Heikki
parent 16a35ea3
...@@ -3039,10 +3039,22 @@ logs_empty_and_mark_files_at_shutdown(void) ...@@ -3039,10 +3039,22 @@ logs_empty_and_mark_files_at_shutdown(void)
mutex_enter(&kernel_mutex); mutex_enter(&kernel_mutex);
/* Check that there are no longer transactions. We need this wait /* We need the monitor threads to stop before we proceed with a
even for the 'very fast' shutdown, because the InnoDB layer may have normal shutdown. In case of very fast shutdown, however, we can
committed or prepared transactions and we don't want to lose proceed without waiting for monitor threads. */
them. */
if (srv_fast_shutdown < 2
&& (srv_error_monitor_active
|| srv_lock_timeout_and_monitor_active)) {
mutex_exit(&kernel_mutex);
goto loop;
}
/* Check that there are no longer transactions. We need this wait even
for the 'very fast' shutdown, because the InnoDB layer may have
committed or prepared transactions and we don't want to lose them. */
if (trx_n_mysql_transactions > 0 if (trx_n_mysql_transactions > 0
|| UT_LIST_GET_LEN(trx_sys->trx_list) > 0) { || UT_LIST_GET_LEN(trx_sys->trx_list) > 0) {
...@@ -3163,22 +3175,8 @@ logs_empty_and_mark_files_at_shutdown(void) ...@@ -3163,22 +3175,8 @@ logs_empty_and_mark_files_at_shutdown(void)
goto loop; goto loop;
} }
/* The lock timeout thread should now have exited */
if (srv_lock_timeout_and_monitor_active) {
goto loop;
}
/* We now let also the InnoDB error monitor thread to exit */
srv_shutdown_state = SRV_SHUTDOWN_LAST_PHASE; srv_shutdown_state = SRV_SHUTDOWN_LAST_PHASE;
if (srv_error_monitor_active) {
goto loop;
}
/* Make some checks that the server really is quiet */ /* Make some checks that the server really is quiet */
ut_a(srv_n_threads_active[SRV_MASTER] == 0); ut_a(srv_n_threads_active[SRV_MASTER] == 0);
ut_a(buf_all_freed()); ut_a(buf_all_freed());
......
...@@ -1881,6 +1881,7 @@ srv_lock_timeout_and_monitor_thread( ...@@ -1881,6 +1881,7 @@ srv_lock_timeout_and_monitor_thread(
double time_elapsed; double time_elapsed;
time_t current_time; time_t current_time;
time_t last_table_monitor_time; time_t last_table_monitor_time;
time_t last_tablespace_monitor_time;
time_t last_monitor_time; time_t last_monitor_time;
ibool some_waits; ibool some_waits;
double wait_time; double wait_time;
...@@ -1893,6 +1894,7 @@ srv_lock_timeout_and_monitor_thread( ...@@ -1893,6 +1894,7 @@ srv_lock_timeout_and_monitor_thread(
UT_NOT_USED(arg); UT_NOT_USED(arg);
srv_last_monitor_time = time(NULL); srv_last_monitor_time = time(NULL);
last_table_monitor_time = time(NULL); last_table_monitor_time = time(NULL);
last_tablespace_monitor_time = time(NULL);
last_monitor_time = time(NULL); last_monitor_time = time(NULL);
loop: loop:
srv_lock_timeout_and_monitor_active = TRUE; srv_lock_timeout_and_monitor_active = TRUE;
...@@ -1929,9 +1931,8 @@ srv_lock_timeout_and_monitor_thread( ...@@ -1929,9 +1931,8 @@ srv_lock_timeout_and_monitor_thread(
} }
if (srv_print_innodb_tablespace_monitor if (srv_print_innodb_tablespace_monitor
&& difftime(current_time, last_table_monitor_time) > 60) { && difftime(current_time, last_tablespace_monitor_time) > 60) {
last_tablespace_monitor_time = time(NULL);
last_table_monitor_time = time(NULL);
fputs("========================" fputs("========================"
"========================\n", "========================\n",
...@@ -2128,7 +2129,7 @@ srv_error_monitor_thread( ...@@ -2128,7 +2129,7 @@ srv_error_monitor_thread(
os_thread_sleep(2000000); os_thread_sleep(2000000);
if (srv_shutdown_state < SRV_SHUTDOWN_LAST_PHASE) { if (srv_shutdown_state < SRV_SHUTDOWN_CLEANUP) {
goto loop; goto loop;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment