diff options
Diffstat (limited to 'innobase/srv')
-rw-r--r-- | innobase/srv/srv0que.c | 2 | ||||
-rw-r--r-- | innobase/srv/srv0srv.c | 990 | ||||
-rw-r--r-- | innobase/srv/srv0start.c | 102 | ||||
-rw-r--r-- | innobase/srv/ts/makefile | 15 | ||||
-rw-r--r-- | innobase/srv/ts/tsdbc.c | 118 | ||||
-rw-r--r-- | innobase/srv/ts/tssrv.c | 39 |
6 files changed, 43 insertions, 1223 deletions
diff --git a/innobase/srv/srv0que.c b/innobase/srv/srv0que.c index 4d36adfefa4..ac8bd7d0e65 100644 --- a/innobase/srv/srv0que.c +++ b/innobase/srv/srv0que.c @@ -83,7 +83,9 @@ srv_que_task_enqueue_low( { ut_ad(thr); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ UT_LIST_ADD_LAST(queue, srv_sys->tasks, thr); diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index d2368c5341f..838e63b3e25 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -34,12 +34,9 @@ Created 10/8/1995 Heikki Tuuri #include "sync0sync.h" #include "sync0ipm.h" #include "thr0loc.h" -#include "com0com.h" -#include "com0shm.h" #include "que0que.h" #include "srv0que.h" #include "log0recv.h" -#include "odbc0odbc.h" #include "pars0pars.h" #include "usr0sess.h" #include "lock0lock.h" @@ -253,9 +250,6 @@ ibool srv_use_adaptive_hash_indexes = TRUE; ulint srv_n_spin_wait_rounds = 20; ulint srv_spin_wait_delay = 5; ibool srv_priority_boost = TRUE; -char srv_endpoint_name[COM_MAX_ADDR_LEN]; -ulint srv_n_com_threads = ULINT_MAX; -ulint srv_n_worker_threads = ULINT_MAX; ibool srv_print_thread_releases = FALSE; ibool srv_print_lock_waits = FALSE; @@ -263,14 +257,14 @@ ibool srv_print_buf_io = FALSE; ibool srv_print_log_io = FALSE; ibool srv_print_latch_waits = FALSE; -ulint srv_n_rows_inserted = 0; -ulint srv_n_rows_updated = 0; -ulint srv_n_rows_deleted = 0; -ulint srv_n_rows_read = 0; -ulint srv_n_rows_inserted_old = 0; -ulint srv_n_rows_updated_old = 0; -ulint srv_n_rows_deleted_old = 0; -ulint srv_n_rows_read_old = 0; +ulint srv_n_rows_inserted = 0; +ulint srv_n_rows_updated = 0; +ulint srv_n_rows_deleted = 0; +ulint srv_n_rows_read = 0; +static ulint srv_n_rows_inserted_old = 0; +static ulint srv_n_rows_updated_old = 0; +static ulint srv_n_rows_deleted_old = 0; +static ulint srv_n_rows_read_old = 0; /* Set the following to 0 if you want InnoDB to write messages on @@ -630,7 +624,9 @@ srv_suspend_thread(void) ulint slot_no; ulint type; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ slot_no = thr_local_get_slot_no(os_thread_get_curr_id()); @@ -681,7 +677,9 @@ srv_release_threads( ut_ad(type >= SRV_WORKER); ut_ad(type <= SRV_MASTER); ut_ad(n > 0); +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ for (i = 0; i < OS_THREAD_MAX_N; i++) { @@ -741,924 +739,9 @@ srv_get_thread_type(void) return(type); } -/*********************************************************************** -Increments by 1 the count of active threads of the type given -and releases master thread if necessary. */ -static -void -srv_inc_thread_count( -/*=================*/ - ulint type) /* in: type of the thread */ -{ - mutex_enter(&kernel_mutex); - - srv_activity_count++; - - srv_n_threads_active[type]++; - - if (srv_n_threads_active[SRV_MASTER] == 0) { - - srv_release_threads(SRV_MASTER, 1); - } - - mutex_exit(&kernel_mutex); -} - -/*********************************************************************** -Decrements by 1 the count of active threads of the type given. */ -static -void -srv_dec_thread_count( -/*=================*/ - ulint type) /* in: type of the thread */ - -{ - mutex_enter(&kernel_mutex); - - /* FIXME: the following assertion sometimes fails: */ - - if (srv_n_threads_active[type] == 0) { - printf("Error: thread type %lu\n", (ulong) type); - - ut_ad(0); - } - - srv_n_threads_active[type]--; - - mutex_exit(&kernel_mutex); -} - -/*********************************************************************** -Calculates the number of allowed utility threads for a thread to decide if -it has to suspend itself in the thread table. */ -static -ulint -srv_max_n_utilities( -/*================*/ - /* out: maximum number of allowed utilities - of the type given */ - ulint type) /* in: utility type */ -{ - ulint ret; - - if (srv_n_threads_active[SRV_COM] == 0) { - if (srv_meter[type] > srv_meter_low_water[type]) { - return(srv_n_threads[type] / 2); - } else { - return(0); - } - } else { - - if (srv_meter[type] < srv_meter_foreground[type]) { - return(0); - } - ret = 1 + ((srv_n_threads[type] - * (ulint)(srv_meter[type] - srv_meter_foreground[type])) - / (ulint)(1000 - srv_meter_foreground[type])); - if (ret > srv_n_threads[type]) { - return(srv_n_threads[type]); - } else { - return(ret); - } - } -} - -/*********************************************************************** -Increments the utility meter by the value given and releases utility -threads if necessary. */ - -void -srv_increment_meter( -/*================*/ - ulint type, /* in: utility type */ - ulint n) /* in: value to add to meter */ -{ - ulint m; - - mutex_enter(&kernel_mutex); - - srv_meter[type] += n; - - m = srv_max_n_utilities(type); - - if (m > srv_n_threads_active[type]) { - - srv_release_threads(type, m - srv_n_threads_active[type]); - } - - mutex_exit(&kernel_mutex); -} - -/*********************************************************************** -Releases max number of utility threads if no queries are active and -the high-water mark for the utility is exceeded. */ - -void -srv_release_max_if_no_queries(void) -/*===============================*/ -{ - ulint m; - ulint type; - - mutex_enter(&kernel_mutex); - - if (srv_n_threads_active[SRV_COM] > 0) { - mutex_exit(&kernel_mutex); - - return; - } - - type = SRV_RECOVERY; - - m = srv_n_threads[type] / 2; - - if ((srv_meter[type] > srv_meter_high_water[type]) - && (srv_n_threads_active[type] < m)) { - - srv_release_threads(type, m - srv_n_threads_active[type]); - - printf("Releasing max background\n"); - } - - 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. */ -static -void -srv_release_one_if_no_queries(void) -/*===============================*/ -{ - ulint m; - ulint type; - - mutex_enter(&kernel_mutex); - - if (srv_n_threads_active[SRV_COM] > 0) { - mutex_exit(&kernel_mutex); - - return; - } - - type = SRV_RECOVERY; - - m = 1; - - if ((srv_meter[type] > srv_meter_high_water2[type]) - && (srv_n_threads_active[type] < m)) { - - srv_release_threads(type, m - srv_n_threads_active[type]); - - printf("Releasing one background\n"); - } - - mutex_exit(&kernel_mutex); -} - -/*********************************************************************** -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. */ -static -void -srv_decrement_meter( -/*================*/ - ulint type, /* in: utility type */ - ulint n) /* in: value to subtract from meter */ -{ - ulint opt; - os_event_t event; - - mutex_enter(&kernel_mutex); - - if (srv_meter[type] < n) { - srv_meter[type] = 0; - } else { - srv_meter[type] -= n; - } - - opt = srv_max_n_utilities(type); - - if (opt < srv_n_threads_active[type]) { - - event = srv_suspend_thread(); - mutex_exit(&kernel_mutex); - - os_event_wait(event); - } else { - mutex_exit(&kernel_mutex); - } -} -#endif - -/************************************************************************* -Implements the server console. */ - -ulint -srv_console( -/*========*/ - /* out: return code, not used */ - void* arg) /* in: argument, not used */ -{ - char command[256]; - - UT_NOT_USED(arg); - - mutex_enter(&kernel_mutex); - srv_table_reserve_slot(SRV_CONSOLE); - mutex_exit(&kernel_mutex); - - os_event_wait(srv_sys->operational); - - for (;;) { - scanf("%s", command); - - srv_inc_thread_count(SRV_CONSOLE); - - if (command[0] == 'c') { - printf("Making checkpoint\n"); - - log_make_checkpoint_at(ut_dulint_max, TRUE); - - printf("Checkpoint completed\n"); - - } else if (command[0] == 'd') { - srv_sim_disk_wait_pct = atoi(command + 1); - - printf( - "Starting disk access simulation with pct %lu\n", - (ulong) srv_sim_disk_wait_pct); - } else { - printf("\nNot supported!\n"); - } - - srv_dec_thread_count(SRV_CONSOLE); - } - - return(0); /* Not reached */ -} - -/************************************************************************* -Creates the first communication endpoint for the server. This -first call also initializes the com0com.* module. */ - -void -srv_communication_init( -/*===================*/ - char* endpoint) /* in: server address */ -{ - ulint ret; - ulint len; - - srv_sys->endpoint = com_endpoint_create(COM_SHM); - - ut_a(srv_sys->endpoint); - - len = ODBC_DATAGRAM_SIZE; - - ret = com_endpoint_set_option(srv_sys->endpoint, - COM_OPT_MAX_DGRAM_SIZE, - (byte*)&len, sizeof(ulint)); - ut_a(ret == 0); - - ret = com_bind(srv_sys->endpoint, endpoint, ut_strlen(endpoint)); - - ut_a(ret == 0); -} - -#ifdef notdefined - -/************************************************************************* -Implements the recovery utility. */ -static -ulint -srv_recovery_thread( -/*================*/ - /* out: return code, not used */ - void* arg) /* in: not used */ -{ - ulint slot_no; - os_event_t event; - - UT_NOT_USED(arg); - - slot_no = srv_table_reserve_slot(SRV_RECOVERY); - - os_event_wait(srv_sys->operational); - - for (;;) { - /* Finish a possible recovery */ - - srv_inc_thread_count(SRV_RECOVERY); - -/* recv_recovery_from_checkpoint_finish(); */ - - srv_dec_thread_count(SRV_RECOVERY); - - mutex_enter(&kernel_mutex); - event = srv_suspend_thread(); - mutex_exit(&kernel_mutex); - - /* Wait for somebody to release this thread; (currently, this - should never be released) */ - - os_event_wait(event); - } - - return(0); -} - -/************************************************************************* -Implements the purge utility. */ - -ulint -srv_purge_thread( -/*=============*/ - /* out: return code, not used */ - void* arg) /* in: not used */ -{ - UT_NOT_USED(arg); - - os_event_wait(srv_sys->operational); - - for (;;) { - trx_purge(); - } - - return(0); -} -#endif /* notdefined */ - -/************************************************************************* -Creates the utility threads. */ - -void -srv_create_utility_threads(void) -/*============================*/ -{ -/* os_thread_t thread; - os_thread_id_t thr_id; */ - ulint i; - - mutex_enter(&kernel_mutex); - - srv_n_threads[SRV_RECOVERY] = 1; - srv_n_threads_active[SRV_RECOVERY] = 1; - - mutex_exit(&kernel_mutex); - - for (i = 0; i < 1; i++) { - /* thread = os_thread_create(srv_recovery_thread, NULL, &thr_id); */ - - /* ut_a(thread); */ - } - -/* thread = os_thread_create(srv_purge_thread, NULL, &thr_id); - - ut_a(thread); */ -} - -#ifdef notdefined -/************************************************************************* -Implements the communication threads. */ -static -ulint -srv_com_thread( -/*===========*/ - /* out: return code; not used */ - void* arg) /* in: not used */ -{ - byte* msg_buf; - byte* addr_buf; - ulint msg_len; - ulint addr_len; - ulint ret; - - UT_NOT_USED(arg); - - srv_table_reserve_slot(SRV_COM); - - os_event_wait(srv_sys->operational); - - msg_buf = mem_alloc(com_endpoint_get_max_size(srv_sys->endpoint)); - addr_buf = mem_alloc(COM_MAX_ADDR_LEN); - - for (;;) { - ret = com_recvfrom(srv_sys->endpoint, msg_buf, - com_endpoint_get_max_size(srv_sys->endpoint), - &msg_len, (char*)addr_buf, COM_MAX_ADDR_LEN, - &addr_len); - ut_a(ret == 0); - - srv_inc_thread_count(SRV_COM); - - sess_process_cli_msg(msg_buf, msg_len, addr_buf, addr_len); - -/* srv_increment_meter(SRV_RECOVERY, 1); */ - - srv_dec_thread_count(SRV_COM); - - /* Release one utility thread for each utility if - high water mark 2 is exceeded and there are no - active queries. This is done to utilize possible - quiet time in the server. */ - - srv_release_one_if_no_queries(); - } - - return(0); -} -#endif - -/************************************************************************* -Creates the communication threads. */ - -void -srv_create_com_threads(void) -/*========================*/ -{ - /* os_thread_t thread; - os_thread_id_t thr_id; */ - ulint i; - - srv_n_threads[SRV_COM] = srv_n_com_threads; - - for (i = 0; i < srv_n_com_threads; i++) { - /* thread = os_thread_create(srv_com_thread, NULL, &thr_id); */ - /* ut_a(thread); */ - } -} - -#ifdef notdefined -/************************************************************************* -Implements the worker threads. */ -static -ulint -srv_worker_thread( -/*==============*/ - /* out: return code, not used */ - void* arg) /* in: not used */ -{ - os_event_t event; - - UT_NOT_USED(arg); - - srv_table_reserve_slot(SRV_WORKER); - - os_event_wait(srv_sys->operational); - - for (;;) { - mutex_enter(&kernel_mutex); - event = srv_suspend_thread(); - mutex_exit(&kernel_mutex); - - /* Wait for somebody to release this thread */ - os_event_wait(event); - - srv_inc_thread_count(SRV_WORKER); - - /* Check in the server task queue if there is work for this - thread, and do the work */ - - srv_que_task_queue_check(); - - srv_dec_thread_count(SRV_WORKER); - - /* Release one utility thread for each utility if - high water mark 2 is exceeded and there are no - active queries. This is done to utilize possible - quiet time in the server. */ - - srv_release_one_if_no_queries(); - } - - return(0); -} -#endif - -/************************************************************************* -Creates the worker threads. */ - -void -srv_create_worker_threads(void) -/*===========================*/ -{ -/* os_thread_t thread; - os_thread_id_t thr_id; */ - ulint i; - - srv_n_threads[SRV_WORKER] = srv_n_worker_threads; - srv_n_threads_active[SRV_WORKER] = srv_n_worker_threads; - - for (i = 0; i < srv_n_worker_threads; i++) { - /* thread = os_thread_create(srv_worker_thread, NULL, &thr_id); */ - /* ut_a(thread); */ - } -} - -#ifdef notdefined -/************************************************************************* -Reads a keyword and a value from a file. */ - -ulint -srv_read_init_val( -/*==============*/ - /* out: DB_SUCCESS or error code */ - FILE* initfile, /* in: file pointer */ - char* keyword, /* in: keyword before value(s), or NULL if - no keyword read */ - char* str_buf, /* in/out: buffer for a string value to read, - buffer size must be 10000 bytes, if NULL - then not read */ - ulint* num_val, /* out: numerical value to read, if NULL - then not read */ - ibool print_not_err) /* in: if TRUE, then we will not print - error messages to console */ -{ - ulint ret; - char scan_buf[10000]; - - if (keyword == NULL) { - - goto skip_keyword; - } - - ret = fscanf(initfile, "%9999s", scan_buf); - - if (ret == 0 || ret == EOF || 0 != ut_strcmp(scan_buf, keyword)) { - if (print_not_err) { - - return(DB_ERROR); - } - - printf("Error in InnoDB booting: keyword %s not found\n", - keyword); - printf("from the initfile!\n"); - - return(DB_ERROR); - } -skip_keyword: - if (num_val == NULL && str_buf == NULL) { - - return(DB_SUCCESS); - } - - ret = fscanf(initfile, "%9999s", scan_buf); - - if (ret == EOF || ret == 0) { - if (print_not_err) { - - return(DB_ERROR); - } - - printf( - "Error in InnoDB booting: could not read first value after %s\n", - keyword); - printf("from the initfile!\n"); - - return(DB_ERROR); - } - - if (str_buf) { - ut_memcpy(str_buf, scan_buf, 10000); - - printf("init keyword %s value %s read\n", keyword, str_buf); - - if (!num_val) { - return(DB_SUCCESS); - } - - ret = fscanf(initfile, "%9999s", scan_buf); - - if (ret == EOF || ret == 0) { - - if (print_not_err) { - - return(DB_ERROR); - } - - printf( - "Error in InnoDB booting: could not read second value after %s\n", - keyword); - printf("from the initfile!\n"); - - return(DB_ERROR); - } - } - - if (ut_strlen(scan_buf) > 9) { - - if (print_not_err) { - - return(DB_ERROR); - } - - printf( - "Error in InnoDB booting: numerical value too big after %s\n", - keyword); - printf("in the initfile!\n"); - - return(DB_ERROR); - } - - *num_val = (ulint)atoi(scan_buf); - - if (*num_val >= 1000000000) { - - if (print_not_err) { - - return(DB_ERROR); - } - - printf( - "Error in InnoDB booting: numerical value too big after %s\n", - keyword); - printf("in the initfile!\n"); - - return(DB_ERROR); - } - - printf("init keyword %s value %lu read\n", keyword, *num_val); - - return(DB_SUCCESS); -} - -/************************************************************************* -Reads keywords and values from an initfile. */ - -ulint -srv_read_initfile( -/*==============*/ - /* out: DB_SUCCESS or error code */ - FILE* initfile) /* in: file pointer */ -{ - char str_buf[10000]; - ulint n; - ulint i; - ulint ulint_val; - ulint val1; - ulint val2; - ulint err; - - err = srv_read_init_val(initfile, "INNOBASE_DATA_HOME_DIR", - str_buf, NULL, FALSE); - if (err != DB_SUCCESS) return(err); - - srv_data_home = ut_malloc(ut_strlen(str_buf) + 1); - ut_memcpy(srv_data_home, str_buf, ut_strlen(str_buf) + 1); - - err = srv_read_init_val(initfile,"TABLESPACE_NUMBER_OF_DATA_FILES", - NULL, &n, FALSE); - if (err != DB_SUCCESS) return(err); - - srv_n_data_files = n; - - srv_data_file_names = ut_malloc(n * sizeof(char*)); - srv_data_file_sizes = ut_malloc(n * sizeof(ulint)); - - for (i = 0; i < n; i++) { - err = srv_read_init_val(initfile, - "DATA_FILE_PATH_AND_SIZE_MB", - str_buf, &ulint_val, FALSE); - if (err != DB_SUCCESS) return(err); - - srv_data_file_names[i] = ut_malloc(ut_strlen(str_buf) + 1); - ut_memcpy(srv_data_file_names[i], str_buf, - ut_strlen(str_buf) + 1); - srv_data_file_sizes[i] = ulint_val - * ((1024 * 1024) / UNIV_PAGE_SIZE); - } - - err = srv_read_init_val(initfile, - "NUMBER_OF_MIRRORED_LOG_GROUPS", NULL, - &srv_n_log_groups, FALSE); - if (err != DB_SUCCESS) return(err); - - err = srv_read_init_val(initfile, - "NUMBER_OF_LOG_FILES_IN_GROUP", NULL, - &srv_n_log_files, FALSE); - if (err != DB_SUCCESS) return(err); - - err = srv_read_init_val(initfile, "LOG_FILE_SIZE_KB", NULL, - &srv_log_file_size, FALSE); - if (err != DB_SUCCESS) return(err); - - srv_log_file_size = srv_log_file_size / (UNIV_PAGE_SIZE / 1024); - - srv_log_group_home_dirs = ut_malloc(srv_n_log_files * sizeof(char*)); - - for (i = 0; i < srv_n_log_groups; i++) { - - err = srv_read_init_val(initfile, - "INNOBASE_LOG_GROUP_HOME_DIR", - str_buf, NULL, FALSE); - if (err != DB_SUCCESS) return(err); - - srv_log_group_home_dirs[i] = ut_malloc(ut_strlen(str_buf) + 1); - ut_memcpy(srv_log_group_home_dirs[i], str_buf, - ut_strlen(str_buf) + 1); - } - - err = srv_read_init_val(initfile, "INNOBASE_LOG_ARCH_DIR", - str_buf, NULL, FALSE); - if (err != DB_SUCCESS) return(err); - - srv_arch_dir = ut_malloc(ut_strlen(str_buf) + 1); - ut_memcpy(srv_arch_dir, str_buf, ut_strlen(str_buf) + 1); - - err = srv_read_init_val(initfile, "LOG_ARCHIVE_ON(1/0)", NULL, - &srv_log_archive_on, FALSE); - if (err != DB_SUCCESS) return(err); - - err = srv_read_init_val(initfile, "LOG_BUFFER_SIZE_KB", NULL, - &srv_log_buffer_size, FALSE); - if (err != DB_SUCCESS) return(err); - - srv_log_buffer_size = srv_log_buffer_size / (UNIV_PAGE_SIZE / 1024); - - err = srv_read_init_val(initfile, "FLUSH_LOG_AT_TRX_COMMIT(1/0)", NULL, - &srv_flush_log_at_trx_commit, FALSE); - if (err != DB_SUCCESS) return(err); - - err = srv_read_init_val(initfile, "BUFFER_POOL_SIZE_MB", NULL, - &srv_pool_size, FALSE); - if (err != DB_SUCCESS) return(err); - - srv_pool_size = srv_pool_size * ((1024 * 1024) / UNIV_PAGE_SIZE); - - err = srv_read_init_val(initfile, "ADDITIONAL_MEM_POOL_SIZE_MB", NULL, - &srv_mem_pool_size, FALSE); - if (err != DB_SUCCESS) return(err); - - srv_mem_pool_size = srv_mem_pool_size * 1024 * 1024; - - srv_lock_table_size = 20 * srv_pool_size; - - err = srv_read_init_val(initfile, "NUMBER_OF_FILE_IO_THREADS", NULL, - &srv_n_file_io_threads, FALSE); - if (err != DB_SUCCESS) return(err); - - err = srv_read_init_val(initfile, "SRV_RECOVER_FROM_BACKUP", - NULL, NULL, TRUE); - if (err == DB_SUCCESS) { - srv_archive_recovery = TRUE; - srv_archive_recovery_limit_lsn = ut_dulint_max; - - err = srv_read_init_val(initfile, NULL, NULL, &val1, TRUE); - err = srv_read_init_val(initfile, NULL, NULL, &val2, TRUE); - - if (err == DB_SUCCESS) { - srv_archive_recovery_limit_lsn = - ut_dulint_create(val1, val2); - } - } - - /* err = srv_read_init_val(initfile, - "SYNC_NUMBER_OF_SPIN_WAIT_ROUNDS", NULL, - &srv_n_spin_wait_rounds); - - err = srv_read_init_val(initfile, "SYNC_SPIN_WAIT_DELAY", NULL, - &srv_spin_wait_delay); */ - return(DB_SUCCESS); -} - -/************************************************************************* -Reads keywords and a values from an initfile. In case of an error, exits -from the process. */ - -void -srv_read_initfile( -/*==============*/ - FILE* initfile) /* in: file pointer */ -{ - char str_buf[10000]; - ulint ulint_val; - - srv_read_init_val(initfile, FALSE, "SRV_ENDPOINT_NAME", str_buf, - &ulint_val); - ut_a(ut_strlen(str_buf) < COM_MAX_ADDR_LEN); - - ut_memcpy(srv_endpoint_name, str_buf, COM_MAX_ADDR_LEN); - - srv_read_init_val(initfile, TRUE, "SRV_N_COM_THREADS", str_buf, - &srv_n_com_threads); - - srv_read_init_val(initfile, TRUE, "SRV_N_WORKER_THREADS", str_buf, - &srv_n_worker_threads); - - srv_read_init_val(initfile, TRUE, "SYNC_N_SPIN_WAIT_ROUNDS", str_buf, - &srv_n_spin_wait_rounds); - - srv_read_init_val(initfile, TRUE, "SYNC_SPIN_WAIT_DELAY", str_buf, - &srv_spin_wait_delay); - - srv_read_init_val(initfile, TRUE, "THREAD_PRIORITY_BOOST", str_buf, - &srv_priority_boost); - - srv_read_init_val(initfile, TRUE, "N_SPACES", str_buf, &srv_n_spaces); - srv_read_init_val(initfile, TRUE, "N_FILES", str_buf, &srv_n_files); - srv_read_init_val(initfile, TRUE, "FILE_SIZE", str_buf, - &srv_file_size); - - srv_read_init_val(initfile, TRUE, "N_LOG_GROUPS", str_buf, - &srv_n_log_groups); - srv_read_init_val(initfile, TRUE, "N_LOG_FILES", str_buf, - &srv_n_log_files); - srv_read_init_val(initfile, TRUE, "LOG_FILE_SIZE", str_buf, - &srv_log_file_size); - srv_read_init_val(initfile, TRUE, "LOG_ARCHIVE_ON", str_buf, - &srv_log_archive_on); - srv_read_init_val(initfile, TRUE, "LOG_BUFFER_SIZE", str_buf, - &srv_log_buffer_size); - srv_read_init_val(initfile, TRUE, "FLUSH_LOG_AT_TRX_COMMIT", str_buf, - &srv_flush_log_at_trx_commit); - - - srv_read_init_val(initfile, TRUE, "POOL_SIZE", str_buf, - &srv_pool_size); - srv_read_init_val(initfile, TRUE, "MEM_POOL_SIZE", str_buf, - &srv_mem_pool_size); - srv_read_init_val(initfile, TRUE, "LOCK_TABLE_SIZE", str_buf, - &srv_lock_table_size); - - srv_read_init_val(initfile, TRUE, "SIM_DISK_WAIT_PCT", str_buf, - &srv_sim_disk_wait_pct); - - srv_read_init_val(initfile, TRUE, "SIM_DISK_WAIT_LEN", str_buf, - &srv_sim_disk_wait_len); - - srv_read_init_val(initfile, TRUE, "SIM_DISK_WAIT_BY_YIELD", str_buf, - &srv_sim_disk_wait_by_yield); - - srv_read_init_val(initfile, TRUE, "SIM_DISK_WAIT_BY_WAIT", str_buf, - &srv_sim_disk_wait_by_wait); - - srv_read_init_val(initfile, TRUE, "MEASURE_CONTENTION", str_buf, - &srv_measure_contention); - - srv_read_init_val(initfile, TRUE, "MEASURE_BY_SPIN", str_buf, - &srv_measure_by_spin); - - - srv_read_init_val(initfile, TRUE, "PRINT_THREAD_RELEASES", str_buf, - &srv_print_thread_releases); - - srv_read_init_val(initfile, TRUE, "PRINT_LOCK_WAITS", str_buf, - &srv_print_lock_waits); - if (srv_print_lock_waits) { - lock_print_waits = TRUE; - } - - srv_read_init_val(initfile, TRUE, "PRINT_BUF_IO", str_buf, - &srv_print_buf_io); - if (srv_print_buf_io) { - buf_debug_prints = TRUE; - } - - srv_read_init_val(initfile, TRUE, "PRINT_LOG_IO", str_buf, - &srv_print_log_io); - if (srv_print_log_io) { - log_debug_writes = TRUE; - } - - srv_read_init_val(initfile, TRUE, "PRINT_PARSED_SQL", str_buf, - &srv_print_parsed_sql); - if (srv_print_parsed_sql) { - pars_print_lexed = TRUE; - } - - srv_read_init_val(initfile, TRUE, "PRINT_LATCH_WAITS", str_buf, - &srv_print_latch_waits); - - srv_read_init_val(initfile, TRUE, "TEST_EXTRA_MUTEXES", str_buf, - &srv_test_extra_mutexes); - srv_read_init_val(initfile, TRUE, "TEST_NOCACHE", str_buf, - &srv_test_nocache); - srv_read_init_val(initfile, TRUE, "TEST_CACHE_EVICT", str_buf, - &srv_test_cache_evict); - - srv_read_init_val(initfile, TRUE, "TEST_SYNC", str_buf, - &srv_test_sync); - srv_read_init_val(initfile, TRUE, "TEST_N_THREADS", str_buf, - &srv_test_n_threads); - srv_read_init_val(initfile, TRUE, "TEST_N_LOOPS", str_buf, - &srv_test_n_loops); - srv_read_init_val(initfile, TRUE, "TEST_N_FREE_RNDS", str_buf, - &srv_test_n_free_rnds); - srv_read_init_val(initfile, TRUE, "TEST_N_RESERVED_RNDS", str_buf, - &srv_test_n_reserved_rnds); - srv_read_init_val(initfile, TRUE, "TEST_N_MUTEXES", str_buf, - &srv_test_n_mutexes); - srv_read_init_val(initfile, TRUE, "TEST_ARRAY_SIZE", str_buf, - &srv_test_array_size); -} -#endif - /************************************************************************* Initializes the server. */ - +static void srv_init(void) /*==========*/ @@ -2100,7 +1183,9 @@ srv_table_reserve_slot_for_mysql(void) srv_slot_t* slot; ulint i; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ i = 0; slot = srv_mysql_table + i; @@ -2130,7 +1215,7 @@ srv_table_reserve_slot_for_mysql(void) (ulong) difftime(ut_time(), slot->suspend_time)); } - ut_a(0); + ut_error; } slot = srv_mysql_table + i; @@ -2165,7 +1250,9 @@ srv_suspend_mysql_thread( ibool had_dict_lock = FALSE; ibool was_declared_inside_innodb = FALSE; +#ifdef UNIV_SYNC_DEBUG ut_ad(!mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ trx = thr_get_trx(thr); @@ -2284,7 +1371,9 @@ srv_release_mysql_thread_if_suspended( srv_slot_t* slot; ulint i; +#ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); +#endif /* UNIV_SYNC_DEBUG */ for (i = 0; i < OS_THREAD_MAX_N; i++) { @@ -2380,6 +1469,13 @@ srv_sprintf_innodb_monitor( buf = buf + strlen(buf); ut_a(buf < buf_end + 1500); + /* Conceptually, srv_innodb_monitor_mutex has a very high latching + order level in sync0sync.h, while dict_foreign_err_mutex has a very + low level 135. Therefore we can reserve the latter mutex here without + a danger of a deadlock of threads. */ + + mutex_enter(&dict_foreign_err_mutex); + if (*dict_foreign_err_buf != '\0') { buf += sprintf(buf, "------------------------\n" @@ -2391,18 +1487,7 @@ srv_sprintf_innodb_monitor( } } - ut_a(buf < buf_end + 1500); - - if (*dict_unique_err_buf != '\0') { - buf += sprintf(buf, -"---------------------------------------------------------------\n" -"LATEST UNIQUE KEY ERROR (is masked in REPLACE or INSERT IGNORE)\n" -"---------------------------------------------------------------\n"); - - if (buf_end - buf > 6000) { - buf+= sprintf(buf, "%.4000s", dict_unique_err_buf); - } - } + mutex_exit(&dict_foreign_err_mutex); ut_a(buf < buf_end + 1500); @@ -2448,7 +1533,7 @@ srv_sprintf_innodb_monitor( "----------------------\n"); buf += sprintf(buf, "Total memory allocated " ULINTPF - "; in additional pool allocated" ULINTPF "\n", + "; in additional pool allocated " ULINTPF "\n", ut_total_allocated_memory, mem_pool_get_reserved(mem_comm_pool)); @@ -2486,13 +1571,13 @@ srv_sprintf_innodb_monitor( #ifdef UNIV_LINUX buf += sprintf(buf, - "Main thread process no. %lu, id %lu, state: %s\n", + "Main thread process no. %lu, id %lu, state: %.29s\n", (ulong) srv_main_thread_process_no, (ulong) srv_main_thread_id, srv_main_thread_op_info); #else buf += sprintf(buf, - "Main thread id %lu, state: %s\n", + "Main thread id %lu, state: %.29s\n", (ulong) srv_main_thread_id, srv_main_thread_op_info); #endif @@ -2765,13 +1850,6 @@ loop: srv_refresh_innodb_monitor_stats(); } -/* mem_print_new_info(); - - if (cnt % 10 == 0) { - - mem_print_info(); - } -*/ sync_array_print_long_waits(); /* Flush stdout and stderr so that a database user gets their output @@ -3244,12 +2322,6 @@ flush_loop: goto background_loop; } -/* mem_print_new_info(); - */ - -#ifdef UNIV_SEARCH_PERF_STAT -/* btr_search_print_info(); */ -#endif /* There is no work for background operations either: suspend master thread to wait for more server activity */ diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index e6fdc95fad0..7b50877709b 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -40,7 +40,6 @@ Created 2/16/1996 Heikki Tuuri #include "rem0rec.h" #include "srv0srv.h" #include "que0que.h" -#include "com0com.h" #include "usr0sess.h" #include "lock0lock.h" #include "trx0roll.h" @@ -447,9 +446,9 @@ io_handler_thread( } #ifdef __WIN__ -#define SRV_PATH_SEPARATOR "\\" +#define SRV_PATH_SEPARATOR '\\' #else -#define SRV_PATH_SEPARATOR "/" +#define SRV_PATH_SEPARATOR '/' #endif /************************************************************************* @@ -477,31 +476,26 @@ srv_normalize_path_for_win( Adds a slash or a backslash to the end of a string if it is missing and the string is not empty. */ +static char* srv_add_path_separator_if_needed( /*=============================*/ - /* out, own: string which has the separator if the + /* out: string which has the separator if the string is not empty */ char* str) /* in: null-terminated character string */ { char* out_str; + ulint len = ut_strlen(str); - if (ut_strlen(str) == 0) { + if (len == 0 || str[len - 1] == SRV_PATH_SEPARATOR) { return(str); } - if (str[ut_strlen(str) - 1] == SRV_PATH_SEPARATOR[0]) { - out_str = ut_malloc(ut_strlen(str) + 1); - - sprintf(out_str, "%s", str); - - return(out_str); - } - - out_str = ut_malloc(ut_strlen(str) + 2); - - sprintf(out_str, "%s%s", str, SRV_PATH_SEPARATOR); + out_str = ut_malloc(len + 2); + memcpy(out_str, str, len); + out_str[len] = SRV_PATH_SEPARATOR; + out_str[len + 1] = 0; return(out_str); } @@ -908,80 +902,6 @@ skip_size_check: return(DB_SUCCESS); } -#ifdef notdefined -/********************************************************************* -This thread is used to measure contention of latches. */ -static -ulint -test_measure_cont( -/*==============*/ - void* arg) -{ - ulint i, j; - ulint pcount, kcount, s_scount, s_xcount, s_mcount, lcount; - - UT_NOT_USED(arg); - - fprintf(stderr, "Starting contention measurement\n"); - - for (i = 0; i < 1000; i++) { - - pcount = 0; - kcount = 0; - s_scount = 0; - s_xcount = 0; - s_mcount = 0; - lcount = 0; - - for (j = 0; j < 100; j++) { - - if (srv_measure_by_spin) { - ut_delay(ut_rnd_interval(0, 20000)); - } else { - os_thread_sleep(20000); - } - - if (kernel_mutex.lock_word) { - kcount++; - } - - if (buf_pool->mutex.lock_word) { - pcount++; - } - - if (log_sys->mutex.lock_word) { - lcount++; - } - - if (btr_search_latch.reader_count) { - s_scount++; - } - - if (btr_search_latch.writer != RW_LOCK_NOT_LOCKED) { - s_xcount++; - } - - if (btr_search_latch.mutex.lock_word) { - s_mcount++; - } - } - - fprintf(stderr, - "Mutex res. l %lu, p %lu, k %lu s x %lu s s %lu s mut %lu of %lu\n", - lcount, pcount, kcount, s_xcount, s_scount, s_mcount, j); - -/* sync_print_wait_info(); */ - - fprintf(stderr, - "log i/o %lu n non sea %lu n succ %lu n h fail %lu\n", - log_sys->n_log_ios, btr_cur_n_non_sea, - btr_search_n_succ, btr_search_n_hash_fail); - } - - return(0); -} -#endif - /******************************************************************** Starts InnoDB and creates a new database if database files are not found and the user wants. Server parameters are @@ -1379,8 +1299,6 @@ NetWare. */ mutex_exit(&(log_sys->mutex)); } - sess_sys_init_at_db_start(); - if (create_new_db) { mtr_start(&mtr); diff --git a/innobase/srv/ts/makefile b/innobase/srv/ts/makefile deleted file mode 100644 index 0b743e37a20..00000000000 --- a/innobase/srv/ts/makefile +++ /dev/null @@ -1,15 +0,0 @@ - - - -include ..\..\makefile.i - -tssrv: ..\srv.lib tssrv.c makefile - $(CCOM) $(CFL) -I.. -I..\.. ..\srv.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\btr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tssrv.c $(LFL) - - - - - - - - diff --git a/innobase/srv/ts/tsdbc.c b/innobase/srv/ts/tsdbc.c deleted file mode 100644 index 83ba081959d..00000000000 --- a/innobase/srv/ts/tsdbc.c +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************ -Database client test program - -(c) 1995 Innobase Oy - -Created 10/10/1995 Heikki Tuuri -*************************************************************************/ - -#include "com0com.h" -#include "com0shm.h" -#include "ut0ut.h" -#include "mem0mem.h" -#include "os0thread.h" -#include "sync0ipm.h" -#include "sync0sync.h" - -byte buf[10000]; -char addr[150]; - -void -test1(void) -/*=======*/ -{ - com_endpoint_t* ep; - ulint ret; - ulint size; - ulint len; - ulint addr_len; - ulint i, j; - ulint tm, oldtm; - - - oldtm = ut_clock(); - - for (i = 0; i < 10000; i++) { - - ut_delay(100); - } - - for (j = 0; j < i / 10; j++) { - - ut_delay(200); - } - - tm = ut_clock(); - printf("Wall clock time for test without server %ld milliseconds\n", - tm - oldtm); - printf("%lu rounds\n", i); - - ep = com_endpoint_create(COM_SHM); - - ut_a(ep); - - size = 8192; - - ret = com_endpoint_set_option(ep, COM_OPT_MAX_DGRAM_SIZE, - (byte*)&size, 0); - - ut_a(ret == 0); - - ret = com_bind(ep, "CLI", 3); - - ut_a(ret == 0); - - printf("Client endpoint created!\n"); - - oldtm = ut_clock(); - - for (i = 0; i < 50000; i++) { - - ret = com_sendto(ep, (byte*)"Hello from client!\n", 18, "ibsrv", 5); - - ut_a(ret == 0); - - ret = com_recvfrom(ep, buf, 10000, &len, addr, 150, &addr_len); - - ut_a(ret == 0); - - buf[len] = '\0'; - addr[addr_len] = '\0'; -/* - printf( - "Message of len %lu\n%s \nreceived from address %s of len %lu\n", - len, buf, addr, addr_len); -*/ - } - - - tm = ut_clock(); - printf("Wall clock time for test %ld milliseconds\n", tm - oldtm); - printf("%lu message pairs\n", i); - - - printf("System calls in com_shm %lu ip_mutex %lu mutex %lu\n", - com_shm_system_call_count, - ip_mutex_system_call_count, - mutex_system_call_count); - - - ret = com_endpoint_free(ep); - - ut_ad(ret == 0); -} - -void -main(void) -/*======*/ -{ - - - - sync_init(); - mem_init(); - - test1(); - - printf("TESTS COMPLETED SUCCESSFULLY!\n"); -} diff --git a/innobase/srv/ts/tssrv.c b/innobase/srv/ts/tssrv.c deleted file mode 100644 index 92b98c4554e..00000000000 --- a/innobase/srv/ts/tssrv.c +++ /dev/null @@ -1,39 +0,0 @@ -/****************************************************** -Test for the database server - -(c) 1995 Innobase Oy - -Created 10/10/1995 Heikki Tuuri -*******************************************************/ - -#include "srv0srv.h" -#include "os0proc.h" -#include "ut0mem.h" - - -/*************************************************************************** -The main function of the server. */ - -void -main( -/*=*/ -#ifdef notdefined - - ulint argc, /* in: number of string arguments given on - the command line */ - char* argv[] -#endif -) /* in: array of character pointers giving - the arguments */ -{ -/* - if (argc != 2) { - printf("Error! Wrong number of command line arguments!\n"); - printf("Usage: ib <init-file-name>\n"); - os_process_exit(1); - } -*/ - srv_boot("init.ib"/*argv[1]*/); - - os_process_exit(0); -} |