summaryrefslogtreecommitdiff
path: root/innobase/srv/srv0srv.c
diff options
context:
space:
mode:
Diffstat (limited to 'innobase/srv/srv0srv.c')
-rw-r--r--innobase/srv/srv0srv.c118
1 files changed, 63 insertions, 55 deletions
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
index 7cd831fe239..90331157289 100644
--- a/innobase/srv/srv0srv.c
+++ b/innobase/srv/srv0srv.c
@@ -868,6 +868,7 @@ srv_release_max_if_no_queries(void)
mutex_exit(&kernel_mutex);
}
+#ifdef notdefined
/***********************************************************************
Releases one utility thread if no queries are active and
the high-water mark 2 for the utility is exceeded. */
@@ -902,7 +903,6 @@ srv_release_one_if_no_queries(void)
mutex_exit(&kernel_mutex);
}
-#ifdef notdefined
/***********************************************************************
Decrements the utility meter by the value given and suspends the calling
thread, which must be an utility thread of the type given, if necessary. */
@@ -1012,6 +1012,8 @@ srv_communication_init(
ut_a(ret == 0);
}
+
+#ifdef notdefined
/*************************************************************************
Implements the recovery utility. */
@@ -1072,6 +1074,7 @@ srv_purge_thread(
return(0);
}
+#endif /* notdefined */
/*************************************************************************
Creates the utility threads. */
@@ -1102,6 +1105,7 @@ srv_create_utility_threads(void)
ut_a(thread); */
}
+#ifdef notdefined
/*************************************************************************
Implements the communication threads. */
static
@@ -1151,6 +1155,7 @@ srv_com_thread(
return(0);
}
+#endif
/*************************************************************************
Creates the communication threads. */
@@ -1171,6 +1176,7 @@ srv_create_com_threads(void)
}
}
+#ifdef notdefined
/*************************************************************************
Implements the worker threads. */
static
@@ -1215,6 +1221,7 @@ srv_worker_thread(
return(0);
}
+#endif
/*************************************************************************
Creates the worker threads. */
@@ -1705,76 +1712,33 @@ srv_init(void)
ut_a(conc_slot->event);
}
}
-
+
/*************************************************************************
-Initializes the synchronization primitives, memory system, and the thread
-local storage. */
+Frees the OS fast mutex created in srv_init(). */
void
-srv_general_init(void)
-/*==================*/
+srv_free(void)
+/*==========*/
{
- sync_init();
- mem_init(srv_mem_pool_size);
- thr_local_init();
+ os_fast_mutex_free(&srv_conc_mutex);
}
-
-#if defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
-/* NetWare requires some cleanup of mutexes */
-
/*************************************************************************
-Deinitializes the synchronization primitives, memory system, and the thread
+Initializes the synchronization primitives, memory system, and the thread
local storage. */
void
-srv_general_free(void)
+srv_general_init(void)
/*==================*/
{
- sync_close();
+ os_sync_init();
+ sync_init();
+ mem_init(srv_mem_pool_size);
+ thr_local_init();
}
-#endif /* __NETWARE__ */
-
/*======================= InnoDB Server FIFO queue =======================*/
-#if defined(__NETWARE__) || defined(SAFE_MUTEX_DETECT_DESTROY)
-/* NetWare requires some cleanup of mutexes */
-
-/*************************************************************************
-Deinitializes the server. */
-
-void
-srv_free(void)
-/*==========*/
-{
- srv_conc_slot_t* conc_slot;
- srv_slot_t* slot;
- ulint i;
-
- for (i = 0; i < OS_THREAD_MAX_N; i++)
- {
- slot = srv_table_get_nth_slot(i);
- os_event_free(slot->event);
- }
-
- /* TODO: free(srv_sys->threads); */
-
- for (i = 0; i < OS_THREAD_MAX_N; i++)
- {
- slot = srv_mysql_table + i;
- os_event_free(slot->event);
- }
-
- /* TODO: free(srv_mysql_table); */
-
- for (i = 0; i < OS_THREAD_MAX_N; i++)
- {
- conc_slot = srv_conc_slots + i;
- os_event_free(conc_slot->event);
- }
-}
-#endif /* __NETWARE__ */
/*************************************************************************
Puts an OS thread to wait if there are too many concurrent threads
@@ -2533,6 +2497,10 @@ srv_lock_timeout_and_monitor_thread(
char* buf;
ulint i;
+#ifdef UNIV_DEBUG_THREAD_CREATION
+ printf("Lock timeout thread starts\n");
+ printf("Thread id %lu\n", os_thread_pf(os_thread_get_curr_id()));
+#endif
UT_NOT_USED(arg);
srv_last_monitor_time = time(NULL);
last_table_monitor_time = time(NULL);
@@ -2673,6 +2641,10 @@ loop:
exit_func:
srv_lock_timeout_and_monitor_active = FALSE;
+ /* We count the number of threads in os_thread_exit(). A created
+ thread should always use that to exit and not use return() to exit. */
+
+ os_thread_exit(NULL);
#ifndef __WIN__
return(NULL);
#else
@@ -2698,6 +2670,10 @@ srv_error_monitor_thread(
ulint cnt = 0;
UT_NOT_USED(arg);
+#ifdef UNIV_DEBUG_THREAD_CREATION
+ printf("Error monitor thread starts\n");
+ printf("Thread id %lu\n", os_thread_pf(os_thread_get_curr_id()));
+#endif
loop:
srv_error_monitor_active = TRUE;
@@ -2734,6 +2710,11 @@ loop:
srv_error_monitor_active = FALSE;
+ /* We count the number of threads in os_thread_exit(). A created
+ thread should always use that to exit and not use return() to exit. */
+
+ os_thread_exit(NULL);
+
#ifndef __WIN__
return(NULL);
#else
@@ -2812,6 +2793,10 @@ srv_master_thread(
UT_NOT_USED(arg);
+#ifdef UNIV_DEBUG_THREAD_CREATION
+ printf("Master thread starts\n");
+ printf("Thread id %lu\n", os_thread_pf(os_thread_get_curr_id()));
+#endif
srv_main_thread_process_no = os_proc_get_number();
srv_main_thread_id = os_thread_pf(os_thread_get_curr_id());
@@ -3047,6 +3032,15 @@ background_loop:
n_tables_to_drop = row_drop_tables_for_mysql_in_background();
+ if (n_tables_to_drop > 0) {
+ /* Do not monopolize the CPU even if there are tables waiting
+ in the background drop queue. (It is essentially a bug if
+ 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);
+ }
+
srv_main_thread_op_info = (char*)"purging";
if (srv_fast_shutdown && srv_shutdown_state > 0) {
@@ -3173,11 +3167,25 @@ suspend_thread:
os_event_wait(event);
+ if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
+ /* This is only extra safety, the thread should exit
+ already when the event wait ends */
+
+ os_thread_exit(NULL);
+ }
+
/* When there is user activity, InnoDB will set the event and the main
thread goes back to loop: */
goto loop;
+ /* We count the number of threads in os_thread_exit(). A created
+ thread should always use that to exit and not use return() to exit.
+ The thread actually never comes here because it is exited in an
+ os_event_wait(). */
+
+ os_thread_exit(NULL);
+
#ifndef __WIN__
return(NULL);
#else