From 5530926e720dd0068e0e408edb7375a512bc4cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 5 Apr 2011 10:37:58 +0300 Subject: Bug 12323643 - CLEAN UP THE INNODB THREAD SHUTDOWN AND ASSERTIONS (WL#5136) On shutdown, do not exit threads in os_event_wait(). This method of exiting was only used by the I/O handler threads. Exit them on a higher level. os_event_wait_low(), os_event_wait_time_low(): Do not exit on shutdown. os_thread_exit(), ut_dbg_assertion_failed(), ut_print_timestamp(): Add attribute cold, so that GCC knows that these functions are rarely invoked and can be optimized for size. os_aio_linux_collect(): Return on shutdown. os_aio_linux_handle(), os_aio_simulated_handle(), os_aio_windows_handle(): Set *message1 = *message2 = NULL and return TRUE on shutdown. fil_aio_wait(): Return on shutdown. logs_empty_and_mark_files_at_shutdown(): Even in very fast shutdown (innodb_fast_shutdown=2), allow the background threads to exit, but skip the flushing and log checkpointing. innobase_shutdown_for_mysql(): Always wait for all the threads to exit. rb:633 approved by Sunny Bains --- storage/innobase/os/os0sync.c | 52 +++++++++---------------------------------- 1 file changed, 10 insertions(+), 42 deletions(-) (limited to 'storage/innobase/os/os0sync.c') diff --git a/storage/innobase/os/os0sync.c b/storage/innobase/os/os0sync.c index b461f9b7c78..41a19843812 100644 --- a/storage/innobase/os/os0sync.c +++ b/storage/innobase/os/os0sync.c @@ -558,10 +558,7 @@ os_event_free( } /**********************************************************//** -Waits for an event object until it is in the signaled state. If -srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS this also exits the -waiting thread when the event becomes signaled (or immediately if the -event is already in the signaled state). +Waits for an event object until it is in the signaled state. Typically, if the event has been signalled after the os_event_reset() we'll return immediately because event->is_set == TRUE. @@ -586,8 +583,6 @@ os_event_wait_low( returned by previous call of os_event_reset(). */ { - ib_int64_t old_signal_count; - #ifdef __WIN__ if(!srv_use_native_conditions) { DWORD err; @@ -600,43 +595,25 @@ os_event_wait_low( err = WaitForSingleObject(event->handle, INFINITE); ut_a(err == WAIT_OBJECT_0); - - if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { - os_thread_exit(NULL); - } return; } #endif - os_fast_mutex_lock(&(event->os_mutex)); + os_fast_mutex_lock(&event->os_mutex); - if (reset_sig_count) { - old_signal_count = reset_sig_count; - } else { - old_signal_count = event->signal_count; + if (!reset_sig_count) { + reset_sig_count = event->signal_count; } - for (;;) { - if (event->is_set == TRUE - || event->signal_count != old_signal_count) { - - os_fast_mutex_unlock(&(event->os_mutex)); - - if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { - - os_thread_exit(NULL); - } - /* Ok, we may return */ - - return; - } - + while (!event->is_set && event->signal_count == reset_sig_count) { os_cond_wait(&(event->cond_var), &(event->os_mutex)); /* Solaris manual said that spurious wakeups may occur: we have to check if the event really has been signaled after we came here to wait */ } + + os_fast_mutex_unlock(&event->os_mutex); } /**********************************************************//** @@ -657,7 +634,6 @@ os_event_wait_time_low( { ibool timed_out = FALSE; - ib_int64_t old_signal_count; #ifdef __WIN__ DWORD time_in_ms; @@ -727,15 +703,12 @@ os_event_wait_time_low( os_fast_mutex_lock(&event->os_mutex); - if (reset_sig_count) { - old_signal_count = reset_sig_count; - } else { - old_signal_count = event->signal_count; + if (!reset_sig_count) { + reset_sig_count = event->signal_count; } do { - if (event->is_set == TRUE - || event->signal_count != old_signal_count) { + if (event->is_set || event->signal_count != reset_sig_count) { break; } @@ -753,11 +726,6 @@ os_event_wait_time_low( os_fast_mutex_unlock(&event->os_mutex); - if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) { - - os_thread_exit(NULL); - } - return(timed_out ? OS_SYNC_TIME_EXCEEDED : 0); } -- cgit v1.2.1