diff options
author | unknown <monty@mashka.mysql.fi> | 2002-07-25 22:46:28 +0300 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2002-07-25 22:46:28 +0300 |
commit | 6ba1aefe909df2651fcace1fe184e3f093d07ab4 (patch) | |
tree | f38c137c73206e3d059517b2bcab6a4a43c957f9 /innobase/srv | |
parent | 29cec51551b7a6be66ebf2048f9045eeb0f59d94 (diff) | |
parent | 714e9c881e5af8bbb54c336d0327bae8e4559019 (diff) | |
download | mariadb-git-6ba1aefe909df2651fcace1fe184e3f093d07ab4.tar.gz |
Merge with 3.23.51
Fixed wrong usage of sprintf() in ha_innodb.cc
BitKeeper/etc/logging_ok:
auto-union
BitKeeper/deleted/.del-global.h~e80d28157acfdcb5:
Auto merged
Docs/manual.ja.texi:
Auto merged
include/config-os2.h:
Auto merged
innobase/btr/btr0btr.c:
Auto merged
innobase/btr/btr0cur.c:
Auto merged
innobase/btr/btr0sea.c:
Auto merged
innobase/buf/buf0buf.c:
Auto merged
innobase/data/data0data.c:
Auto merged
innobase/dict/dict0crea.c:
Auto merged
innobase/dict/dict0dict.c:
Auto merged
innobase/fil/fil0fil.c:
Auto merged
innobase/fsp/fsp0fsp.c:
Auto merged
innobase/ibuf/ibuf0ibuf.c:
Auto merged
innobase/include/buf0buf.ic:
Auto merged
innobase/include/srv0srv.h:
Auto merged
innobase/lock/lock0lock.c:
Auto merged
innobase/log/log0log.c:
Auto merged
innobase/mtr/mtr0mtr.c:
Auto merged
innobase/os/os0file.c:
Auto merged
innobase/page/page0cur.c:
Auto merged
innobase/page/page0page.c:
Auto merged
innobase/rem/rem0cmp.c:
Auto merged
innobase/row/row0ins.c:
Auto merged
innobase/row/row0purge.c:
Auto merged
innobase/row/row0umod.c:
Auto merged
innobase/row/row0upd.c:
Auto merged
innobase/sync/sync0arr.c:
Auto merged
innobase/sync/sync0sync.c:
Auto merged
innobase/trx/trx0roll.c:
Auto merged
innobase/trx/trx0trx.c:
Auto merged
innobase/trx/trx0undo.c:
Auto merged
innobase/ut/ut0ut.c:
Auto merged
isam/pack_isam.c:
Auto merged
mysys/Makefile.am:
Auto merged
sql/ha_innodb.h:
Auto merged
sql/key.cc:
Auto merged
sql/mini_client.cc:
Auto merged
sql/sql_delete.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_update.cc:
Auto merged
sql/table.cc:
Auto merged
support-files/my-huge.cnf.sh:
Auto merged
support-files/my-large.cnf.sh:
Auto merged
support-files/my-medium.cnf.sh:
Auto merged
support-files/my-small.cnf.sh:
Auto merged
Docs/manual.texi:
Merge with 3.23.51
configure.in:
Merge with 3.23.51
include/Makefile.am:
Merge with 3.23.51
innobase/dict/dict0load.c:
Merge with 3.23.51
innobase/include/univ.i:
Merge with 3.23.51
innobase/row/row0mysql.c:
Merge with 3.23.51
innobase/srv/srv0srv.c:
Merge with 3.23.51
innobase/srv/srv0start.c:
Merge with 3.23.51
myisam/mi_cache.c:
Merge with 3.23.51
myisammrg/myrg_rnext.c:
Merge with 3.23.51
myisammrg/myrg_rprev.c:
Merge with 3.23.51
sql/ha_innodb.cc:
Merge with 3.23.51
Changed used of sprintf() to make code portable.
sql/handler.cc:
Indentation change
sql/lex.h:
Comment cleanup
sql/log.cc:
Merge with 3.23.51
sql/log_event.h:
Merge with 3.23.51
sql/mysql_priv.h:
Merge with 3.23.51
sql/mysqld.cc:
Merge with 3.23.51
Cleaned up handling of innodb_flush_log_at_trx_commit
sql/share/portuguese/errmsg.txt:
Merge with 3.23.51
sql/slave.cc:
Not merged as this affects many files; Will be fixed in next changeset
sql/slave.h:
Merge with 3.23.51
sql/sql_acl.cc:
Merge with 3.23.51 (no changes)
sql/sql_db.cc:
Merge with 3.23.51
sql/sql_parse.cc:
Merge with 3.23.51
sql/sql_yacc.yy:
Merge with 3.23.51
(Renamed NO_FOREIGN_KEY_CHECKS and RELAXED_UNIQUE_CHECKS)
support-files/mysql.spec.sh:
Merge with 3.23.51
Diffstat (limited to 'innobase/srv')
-rw-r--r-- | innobase/srv/srv0srv.c | 324 | ||||
-rw-r--r-- | innobase/srv/srv0start.c | 64 |
2 files changed, 256 insertions, 132 deletions
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 39f3566eac8..3efb82eb8eb 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -61,7 +61,7 @@ ulint srv_activity_count = 0; ibool srv_lock_timeout_and_monitor_active = FALSE; ibool srv_error_monitor_active = FALSE; -char* srv_main_thread_op_info = (char *) ""; +char* srv_main_thread_op_info = (char*) ""; /* Server parameters which are read from the initfile */ @@ -238,15 +238,14 @@ ulint srv_n_rows_updated_old = 0; ulint srv_n_rows_deleted_old = 0; ulint srv_n_rows_read_old = 0; -ibool srv_print_innodb_monitor = FALSE; -ibool srv_print_innodb_lock_monitor = FALSE; -ibool srv_print_innodb_tablespace_monitor = FALSE; - /* Set the following to 0 if you want InnoDB to write messages on stderr on startup/shutdown */ ibool srv_print_verbose_log = TRUE; +ibool srv_print_innodb_monitor = FALSE; +ibool srv_print_innodb_lock_monitor = FALSE; +ibool srv_print_innodb_tablespace_monitor = FALSE; ibool srv_print_innodb_table_monitor = FALSE; /* The parameters below are obsolete: */ @@ -278,6 +277,10 @@ i/o handler thread */ char* srv_io_thread_op_info[SRV_MAX_N_IO_THREADS]; +time_t srv_last_monitor_time; + +mutex_t srv_innodb_monitor_mutex; + /* IMPLEMENTATION OF THE SERVER MAIN PROGRAM ========================================= @@ -645,7 +648,7 @@ srv_release_threads( slot = srv_table_get_nth_slot(i); - if ((slot->type == type) && slot->suspended) { + if (slot->in_use && slot->type == type && slot->suspended) { slot->suspended = FALSE; @@ -987,7 +990,6 @@ srv_communication_init( /************************************************************************* Implements the recovery utility. */ -#ifdef NOT_USED static ulint srv_recovery_thread( @@ -1025,7 +1027,7 @@ srv_recovery_thread( return(0); } -#endif + /************************************************************************* Implements the purge utility. */ @@ -1077,7 +1079,6 @@ srv_create_utility_threads(void) /************************************************************************* Implements the communication threads. */ -#ifdef NOT_USED static ulint srv_com_thread( @@ -1125,7 +1126,7 @@ srv_com_thread( return(0); } -#endif + /************************************************************************* Creates the communication threads. */ @@ -1147,7 +1148,6 @@ srv_create_com_threads(void) /************************************************************************* Implements the worker threads. */ -#ifdef NOT_USED static ulint srv_worker_thread( @@ -1190,7 +1190,7 @@ srv_worker_thread( return(0); } -#endif + /************************************************************************* Creates the worker threads. */ @@ -1625,13 +1625,16 @@ srv_init(void) kernel_mutex_temp = mem_alloc(sizeof(mutex_t)); mutex_create(&kernel_mutex); mutex_set_level(&kernel_mutex, SYNC_KERNEL); + + mutex_create(&srv_innodb_monitor_mutex); + mutex_set_level(&srv_innodb_monitor_mutex, SYNC_NO_ORDER_CHECK); srv_sys->threads = mem_alloc(OS_THREAD_MAX_N * sizeof(srv_slot_t)); for (i = 0; i < OS_THREAD_MAX_N; i++) { slot = srv_table_get_nth_slot(i); slot->in_use = FALSE; - slot->type=0; /* Avoid purify errors */ + slot->type=0; /* Avoid purify errors */ slot->event = os_event_create(NULL); ut_a(slot->event); } @@ -1641,6 +1644,7 @@ srv_init(void) for (i = 0; i < OS_THREAD_MAX_N; i++) { slot = srv_mysql_table + i; slot->in_use = FALSE; + slot->type = 0; slot->event = os_event_create(NULL); ut_a(slot->event); } @@ -1900,7 +1904,6 @@ srv_conc_exit_innodb( trx_t* trx) /* in: transaction object associated with the thread */ { - if (srv_thread_concurrency >= 500) { return; @@ -2004,7 +2007,31 @@ srv_table_reserve_slot_for_mysql(void) while (slot->in_use) { i++; - ut_a(i < OS_THREAD_MAX_N); + + if (i >= OS_THREAD_MAX_N) { + + ut_print_timestamp(stderr); + + fprintf(stderr, +" InnoDB: There appear to be %lu MySQL threads currently waiting\n" +"InnoDB: inside InnoDB, which is the upper limit. Cannot continue operation.\n" +"InnoDB: We intentionally generate a seg fault to print a stack trace\n" +"InnoDB: on Linux. But first we print a list of waiting threads.\n", i); + + for (i = 0; i < OS_THREAD_MAX_N; i++) { + + slot = srv_mysql_table + i; + + fprintf(stderr, +"Slot %lu: thread id %lu, type %lu, in use %lu, susp %lu, time %lu\n", + i, (ulint)(slot->id), + slot->type, slot->in_use, + slot->suspended, + (ulint)difftime(ut_time(), slot->suspend_time)); + } + + ut_a(0); + } slot = srv_mysql_table + i; } @@ -2141,104 +2168,113 @@ srv_release_mysql_thread_if_suspended( /* not found */ } -/************************************************************************* -A thread which wakes up threads whose lock wait may have lasted too long. -This also prints the info output by various InnoDB monitors. */ +/********************************************************************** +Sprintfs to a buffer the output of the InnoDB Monitor. */ -#ifndef __WIN__ -void* -#else -ulint -#endif -srv_lock_timeout_and_monitor_thread( -/*================================*/ - /* out: a dummy parameter */ - void* arg) /* in: a dummy parameter required by - os_thread_create */ +void +srv_sprintf_innodb_monitor( +/*=======================*/ + char* buf, /* in/out: buffer which must be at least 4 kB */ + ulint len) /* in: length of the buffer */ { - srv_slot_t* slot; - double time_elapsed; - time_t current_time; - time_t last_monitor_time; - time_t last_table_monitor_time; - ibool some_waits; - double wait_time; - ulint i; - - UT_NOT_USED(arg); - last_monitor_time = time(NULL); - last_table_monitor_time = time(NULL); -loop: - srv_lock_timeout_and_monitor_active = TRUE; + char* buf_end = buf + len - 2000; + double time_elapsed; + time_t current_time; - /* When someone is waiting for a lock, we wake up every second - and check if a timeout has passed for a lock wait */ + mutex_enter(&srv_innodb_monitor_mutex); - os_thread_sleep(1000000); + current_time = time(NULL); - /* In case mutex_exit is not a memory barrier, it is - theoretically possible some threads are left waiting though - the semaphore is already released. Wake up those threads: */ + /* We add 0.001 seconds to time_elapsed to prevent division + by zero if two users happen to call SHOW INNODB STATUS at the same + time */ - sync_arr_wake_threads_if_sema_free(); + time_elapsed = difftime(current_time, srv_last_monitor_time) + + 0.001; - current_time = time(NULL); + srv_last_monitor_time = time(NULL); - time_elapsed = difftime(current_time, last_monitor_time); - - if (time_elapsed > 15) { + ut_a(len >= 4096); - if (srv_print_innodb_monitor) { + buf += sprintf(buf, "\n=====================================\n"); - last_monitor_time = time(NULL); - - printf("=====================================\n"); - ut_print_timestamp(stdout); + ut_sprintf_timestamp(buf); + buf = buf + strlen(buf); - printf(" INNODB MONITOR OUTPUT\n" + buf += sprintf(buf, " INNODB MONITOR OUTPUT\n" "=====================================\n"); - printf("----------\n" + + buf += sprintf(buf, +"Per second values calculated from the last %lu seconds\n", + (ulint)time_elapsed); + + buf += sprintf(buf, "----------\n" "SEMAPHORES\n" "----------\n"); - sync_print(); - printf("------------\n" + sync_print(buf, buf_end); + + buf = buf + strlen(buf); + + buf += sprintf(buf, "------------\n" "TRANSACTIONS\n" "------------\n"); - lock_print_info(); - printf("--------\n" + lock_print_info(buf, buf_end); + buf = buf + strlen(buf); + + buf += sprintf(buf, "--------\n" "FILE I/O\n" "--------\n"); - os_aio_print(); - printf("-------------\n" - "INSERT BUFFER\n" - "-------------\n"); - ibuf_print(); - printf("---\n" + os_aio_print(buf, buf_end); + buf = buf + strlen(buf); + + buf += sprintf(buf, "-------------------------------------\n" + "INSERT BUFFER AND ADAPTIVE HASH INDEX\n" + "-------------------------------------\n"); + ibuf_print(buf, buf_end); + buf = buf + strlen(buf); + + ha_print_info(buf, buf_end, btr_search_sys->hash_index); + buf = buf + strlen(buf); + + buf += sprintf(buf, + "%.2f hash searches/s, %.2f non-hash searches/s\n", + (btr_cur_n_sea - btr_cur_n_sea_old) + / time_elapsed, + (btr_cur_n_non_sea - btr_cur_n_non_sea_old) + / time_elapsed); + btr_cur_n_sea_old = btr_cur_n_sea; + btr_cur_n_non_sea_old = btr_cur_n_non_sea; + + buf += sprintf(buf,"---\n" "LOG\n" "---\n"); - log_print(); - printf("----------------------\n" + log_print(buf, buf_end); + buf = buf + strlen(buf); + + buf += sprintf(buf, "----------------------\n" "BUFFER POOL AND MEMORY\n" "----------------------\n"); - printf( + buf += sprintf(buf, "Total memory allocated %lu; in additional pool allocated %lu\n", ut_total_allocated_memory, mem_pool_get_reserved(mem_comm_pool)); - buf_print_io(); - printf("--------------\n" + buf_print_io(buf, buf_end); + buf = buf + strlen(buf); + + buf += sprintf(buf, "--------------\n" "ROW OPERATIONS\n" "--------------\n"); - printf( + buf += sprintf(buf, "%ld queries inside InnoDB, %ld queries in queue; main thread: %s\n", srv_conc_n_threads, srv_conc_n_waiting_threads, srv_main_thread_op_info); - printf( + buf += sprintf(buf, "Number of rows inserted %lu, updated %lu, deleted %lu, read %lu\n", srv_n_rows_inserted, srv_n_rows_updated, srv_n_rows_deleted, srv_n_rows_read); - printf( + buf += sprintf(buf, "%.2f inserts/s, %.2f updates/s, %.2f deletes/s, %.2f reads/s\n", (srv_n_rows_inserted - srv_n_rows_inserted_old) / time_elapsed, @@ -2254,9 +2290,71 @@ loop: srv_n_rows_deleted_old = srv_n_rows_deleted; srv_n_rows_read_old = srv_n_rows_read; - printf("----------------------------\n" + buf += sprintf(buf, "----------------------------\n" "END OF INNODB MONITOR OUTPUT\n" "============================\n"); + mutex_exit(&srv_innodb_monitor_mutex); +} + +/************************************************************************* +A thread which wakes up threads whose lock wait may have lasted too long. +This also prints the info output by various InnoDB monitors. */ + +#ifndef __WIN__ +void* +#else +ulint +#endif +srv_lock_timeout_and_monitor_thread( +/*================================*/ + /* out: a dummy parameter */ + void* arg) /* in: a dummy parameter required by + os_thread_create */ +{ + srv_slot_t* slot; + double time_elapsed; + time_t current_time; + time_t last_table_monitor_time; + time_t last_monitor_time; + ibool some_waits; + double wait_time; + char* buf; + ulint i; + + UT_NOT_USED(arg); + srv_last_monitor_time = time(NULL); + last_table_monitor_time = time(NULL); + last_monitor_time = time(NULL); +loop: + srv_lock_timeout_and_monitor_active = TRUE; + + /* 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); + + /* In case mutex_exit is not a memory barrier, it is + theoretically possible some threads are left waiting though + the semaphore is already released. Wake up those threads: */ + + sync_arr_wake_threads_if_sema_free(); + + current_time = time(NULL); + + time_elapsed = difftime(current_time, last_monitor_time); + + if (time_elapsed > 15) { + last_monitor_time = time(NULL); + + if (srv_print_innodb_monitor) { + + buf = mem_alloc(100000); + + srv_sprintf_innodb_monitor(buf, 100000); + + printf("%s", buf); + + mem_free(buf); } if (srv_print_innodb_tablespace_monitor @@ -2491,7 +2589,7 @@ srv_master_thread( os_event_set(srv_sys->operational); loop: - srv_main_thread_op_info = (char *) "reserving kernel mutex"; + srv_main_thread_op_info = (char*) "reserving kernel mutex"; n_ios_very_old = log_sys->n_log_ios + buf_pool->n_pages_read + buf_pool->n_pages_written; @@ -2507,18 +2605,19 @@ loop: for (i = 0; i < 10; i++) { n_ios_old = log_sys->n_log_ios + buf_pool->n_pages_read + buf_pool->n_pages_written; - srv_main_thread_op_info = (char *) "sleeping"; + srv_main_thread_op_info = (char*)"sleeping"; os_thread_sleep(1000000); /* 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 = (char*) "doing background drop tables"; + srv_main_thread_op_info = + (char*)"doing background drop tables"; row_drop_tables_for_mysql_in_background(); - srv_main_thread_op_info = (char*) ""; + srv_main_thread_op_info = (char*)""; if (srv_force_recovery >= SRV_FORCE_NO_BACKGROUND) { @@ -2529,8 +2628,9 @@ loop: is issued or the we have specified in my.cnf no flush at transaction commit */ - srv_main_thread_op_info = (char *) "flushing log"; + srv_main_thread_op_info = (char*)"flushing log"; log_flush_up_to(ut_dulint_max, LOG_WAIT_ONE_GROUP); + log_flush_to_disk(); /* If there were less than 10 i/os during the one second sleep, we assume that there is free @@ -2543,11 +2643,13 @@ loop: + buf_pool->n_pages_written; if (n_pend_ios < 3 && (n_ios - n_ios_old < 10)) { srv_main_thread_op_info = - (char *) "doing insert buffer merge"; + (char*)"doing insert buffer merge"; ibuf_contract_for_n_pages(TRUE, 5); - srv_main_thread_op_info = (char *) "flushing log"; + srv_main_thread_op_info = + (char*)"flushing log"; log_flush_up_to(ut_dulint_max, LOG_WAIT_ONE_GROUP); + log_flush_to_disk(); } if (srv_fast_shutdown && srv_shutdown_state > 0) { @@ -2583,21 +2685,23 @@ loop: + buf_pool->n_pages_written; if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) { - srv_main_thread_op_info =(char *) "flushing buffer pool pages"; + srv_main_thread_op_info = (char*) "flushing buffer pool pages"; buf_flush_batch(BUF_FLUSH_LIST, 50, ut_dulint_max); - srv_main_thread_op_info = (char *) "flushing log"; + srv_main_thread_op_info = (char*) "flushing log"; log_flush_up_to(ut_dulint_max, LOG_WAIT_ONE_GROUP); + log_flush_to_disk(); } /* We run a batch of insert buffer merge every 10 seconds, even if the server were active */ - srv_main_thread_op_info = (char *) "doing insert buffer merge"; + srv_main_thread_op_info = (char*)"doing insert buffer merge"; ibuf_contract_for_n_pages(TRUE, 5); - srv_main_thread_op_info = (char *) "flushing log"; + srv_main_thread_op_info = (char*)"flushing log"; log_flush_up_to(ut_dulint_max, LOG_WAIT_ONE_GROUP); + log_flush_to_disk(); /* We run a full purge every 10 seconds, even if the server were active */ @@ -2613,15 +2717,16 @@ loop: goto background_loop; } - srv_main_thread_op_info = (char *) "purging"; + srv_main_thread_op_info = (char*)"purging"; n_pages_purged = trx_purge(); current_time = time(NULL); if (difftime(current_time, last_flush_time) > 1) { - srv_main_thread_op_info = (char *) "flushing log"; + srv_main_thread_op_info = (char*) "flushing log"; log_flush_up_to(ut_dulint_max, LOG_WAIT_ONE_GROUP); + log_flush_to_disk(); last_flush_time = current_time; } } @@ -2630,25 +2735,25 @@ background_loop: /* In this loop we run background operations when the server is quiet and we also come here about once in 10 seconds */ - srv_main_thread_op_info = (char*) "doing background drop tables"; + srv_main_thread_op_info = (char*)"doing background drop tables"; n_tables_to_drop = row_drop_tables_for_mysql_in_background(); - srv_main_thread_op_info = (char*) ""; + srv_main_thread_op_info = (char*)""; - srv_main_thread_op_info = (char*) "flushing buffer pool pages"; + srv_main_thread_op_info = (char*)"flushing buffer pool pages"; /* Flush a few oldest pages to make the checkpoint younger */ n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10, ut_dulint_max); - srv_main_thread_op_info = (char*) "making checkpoint"; + srv_main_thread_op_info = (char*)"making checkpoint"; /* Make a new checkpoint about once in 10 seconds */ log_checkpoint(TRUE, FALSE); - srv_main_thread_op_info = (char *) "reserving kernel mutex"; + srv_main_thread_op_info = (char*)"reserving kernel mutex"; mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { @@ -2661,11 +2766,11 @@ background_loop: /* The server has been quiet for a while: start running background operations */ - srv_main_thread_op_info = (char *) "purging"; + srv_main_thread_op_info = (char*)"purging"; n_pages_purged = trx_purge(); - srv_main_thread_op_info = (char *) "reserving kernel mutex"; + srv_main_thread_op_info = (char*)"reserving kernel mutex"; mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { @@ -2674,10 +2779,10 @@ background_loop: } mutex_exit(&kernel_mutex); - srv_main_thread_op_info = (char *) "doing insert buffer merge"; + srv_main_thread_op_info = (char*)"doing insert buffer merge"; n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20); - srv_main_thread_op_info = (char *) "reserving kernel mutex"; + srv_main_thread_op_info = (char*)"reserving kernel mutex"; mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { @@ -2686,10 +2791,10 @@ background_loop: } mutex_exit(&kernel_mutex); - srv_main_thread_op_info = (char *) "flushing buffer pool pages"; + srv_main_thread_op_info = (char*)"flushing buffer pool pages"; n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max); - srv_main_thread_op_info = (char *) "reserving kernel mutex"; + srv_main_thread_op_info = (char*)"reserving kernel mutex"; mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { @@ -2698,15 +2803,14 @@ background_loop: } mutex_exit(&kernel_mutex); - srv_main_thread_op_info = - (char *) "waiting for buffer pool flush to end"; + srv_main_thread_op_info = (char*) "waiting for buffer pool flush to end"; buf_flush_wait_batch_end(BUF_FLUSH_LIST); - srv_main_thread_op_info = (char *) "making checkpoint"; + srv_main_thread_op_info = (char*)"making checkpoint"; log_checkpoint(TRUE, FALSE); - srv_main_thread_op_info = (char *) "reserving kernel mutex"; + srv_main_thread_op_info = (char*)"reserving kernel mutex"; mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { @@ -2716,7 +2820,7 @@ background_loop: mutex_exit(&kernel_mutex); srv_main_thread_op_info = - (char *) "archiving log (if log archive is on)"; + (char*)"archiving log (if log archive is on)"; log_archive_do(FALSE, &n_bytes_archived); @@ -2742,7 +2846,7 @@ background_loop: master thread to wait for more server activity */ suspend_thread: - srv_main_thread_op_info = (char *) "suspending"; + srv_main_thread_op_info = (char*)"suspending"; mutex_enter(&kernel_mutex); @@ -2756,7 +2860,7 @@ suspend_thread: mutex_exit(&kernel_mutex); - srv_main_thread_op_info = (char *) "waiting for server activity"; + srv_main_thread_op_info = (char*)"waiting for server activity"; os_event_wait(event); diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index f5a0c62aaf9..55e734be3bd 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -433,8 +433,7 @@ Normalizes a directory path for Windows: converts slashes to backslashes. */ void srv_normalize_path_for_win( /*=======================*/ - char* str __attribute__((unused))) - /* in/out: null-terminated character string */ + char* str __attribute__((unused))) /* in/out: null-terminated character string */ { #ifdef __WIN__ ulint i; @@ -619,8 +618,7 @@ open_or_create_log_file( if (k == 0 && i == 0) { arch_space_id = 2 * k + 1 + SRV_LOG_SPACE_FIRST_ID; - fil_space_create((char *) "arch_log_space", arch_space_id, - FIL_LOG); + fil_space_create((char*) "arch_log_space", arch_space_id, FIL_LOG); } else { arch_space_id = ULINT_UNDEFINED; } @@ -839,7 +837,6 @@ open_or_create_data_files( /********************************************************************* This thread is used to measure contention of latches. */ -#ifdef NOT_USED static ulint test_measure_cont( @@ -899,7 +896,7 @@ test_measure_cont( "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(); +/* sync_print_wait_info(); */ fprintf(stderr, "log i/o %lu n non sea %lu n succ %lu n h fail %lu\n", @@ -909,7 +906,7 @@ test_measure_cont( return(0); } -#endif + /******************************************************************** Starts InnoDB and creates a new database if database files are not found and the user wants. Server parameters are @@ -935,27 +932,44 @@ innobase_start_or_create_for_mysql(void) ulint k; mtr_t mtr; +#ifdef UNIV_DEBUG + fprintf(stderr, +"InnoDB: !!!!!!!!!!!!!! UNIV_DEBUG switched on !!!!!!!!!!!!!!!\n"); +#endif + +#ifdef UNIV_SYNC_DEBUG + fprintf(stderr, +"InnoDB: !!!!!!!!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!!!!!!!\n"); +#endif + +#ifdef UNIV_SEARCH_DEBUG + fprintf(stderr, +"InnoDB: !!!!!!!!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!!!!!!!\n"); +#endif + +#ifdef UNIV_MEM_DEBUG + fprintf(stderr, +"InnoDB: !!!!!!!!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!!!!!!!\n"); +#endif + log_do_write = TRUE; /* yydebug = TRUE; */ srv_is_being_started = TRUE; srv_startup_is_before_trx_rollback_phase = TRUE; - if (0 == ut_strcmp(srv_unix_file_flush_method_str, - (char *) "fdatasync")) { - srv_unix_file_flush_method = SRV_UNIX_FDATASYNC; + if (0 == ut_strcmp(srv_unix_file_flush_method_str, "fdatasync")) { + srv_unix_file_flush_method = SRV_UNIX_FDATASYNC; - } else if (0 == ut_strcmp(srv_unix_file_flush_method_str, - (char *) "O_DSYNC")) { - srv_unix_file_flush_method = SRV_UNIX_O_DSYNC; + } else if (0 == ut_strcmp(srv_unix_file_flush_method_str, "O_DSYNC")) { + srv_unix_file_flush_method = SRV_UNIX_O_DSYNC; } else if (0 == ut_strcmp(srv_unix_file_flush_method_str, - (char *) "littlesync")) { - srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC; + "littlesync")) { + srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC; - } else if (0 == ut_strcmp(srv_unix_file_flush_method_str, - (char *) "nosync")) { - srv_unix_file_flush_method = SRV_UNIX_NOSYNC; + } else if (0 == ut_strcmp(srv_unix_file_flush_method_str, "nosync")) { + srv_unix_file_flush_method = SRV_UNIX_NOSYNC; } else { fprintf(stderr, "InnoDB: Unrecognized value %s for innodb_flush_method\n", @@ -1005,7 +1019,7 @@ innobase_start_or_create_for_mysql(void) os_aio_use_native_aio = FALSE; if (!os_aio_use_native_aio) { - os_aio_init(4 * SRV_N_PENDING_IOS_PER_THREAD + os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD * srv_n_file_io_threads, srv_n_file_io_threads, SRV_MAX_N_PENDING_SYNC_IOS); @@ -1350,9 +1364,15 @@ innobase_shutdown_for_mysql(void) "InnoDB: inside InnoDB at shutdown\n", srv_conc_n_threads); } - + + /* + TODO: We should exit the i/o-handler and other utility threads + before freeing all memory. Now this can potentially cause a seg + fault! + */ #ifdef NOT_WORKING_YET - ut_free_all_mem(); -#endif + ut_free_all_mem(); +#endif + return((int) DB_SUCCESS); } |