diff options
author | unknown <marko@hundin.mysql.fi> | 2004-05-27 15:27:43 +0300 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2004-05-27 15:27:43 +0300 |
commit | a1bcf38257fcb124b1ed8432137d82aed95da32d (patch) | |
tree | 566268309e7e64b4e2f6a23700e7b8623521cbbd /innobase/srv | |
parent | d366a2e4c97155d5ea10a7da084d188d7e42222c (diff) | |
download | mariadb-git-a1bcf38257fcb124b1ed8432137d82aed95da32d.tar.gz |
InnoDB cleanup:
Disable log archiving code unless #ifdef UNIV_LOG_ARCHIVE
Remove (char*) casts of string constants; add const qualifiers
Remove some Hot Backup code unless #ifdef UNIV_HOTBACKUP
innobase/btr/btr0cur.c:
Cast away constness from dfield_get_data() result
innobase/buf/buf0buf.c:
Enclose a debug assertion in #ifdef UNIV_SYNC_DEBUG
innobase/buf/buf0rea.c:
Corrected compile error #ifdef UNIV_DEBUG
innobase/dict/dict0boot.c:
Remove (char*) casts of string constants
innobase/dict/dict0crea.c:
Remove (char*) casts of string constants
innobase/dict/dict0dict.c:
Enclosed a debug assertion in #ifdef UNIV_SYNC_DEBUG
Replaced some debug assertions with preprocessor tests
Add const qualifiers to string constants
innobase/dict/dict0load.c:
Remove (char*) casts of string constants
innobase/fil/fil0fil.c:
Remove (char*) casts of string constants
Enclose debug assertions in #ifdef UNIV_SYNC_DEBUG
innobase/ha/ha0ha.c:
Enclose debug assertion in #ifdef UNIV_SYNC_DEBUG
innobase/ibuf/ibuf0ibuf.c:
Remove (char*) casts of string constants
innobase/include/buf0buf.ic:
Add const qualifier to string parameter
innobase/include/fil0fil.h:
Disable log archiving code unless #ifdef UNIV_LOG_ARCHIVE
innobase/include/log0recv.h:
Disable log archiving code unless #ifdef UNIV_LOG_ARCHIVE
Enclose ibbackup specific code in #ifdef UNIV_HOTBACKUP
innobase/include/mem0dbg.ic:
Add const qualifiers to string parameters
innobase/include/srv0srv.h:
Add const qualifiers to string constants
Enclose srv_arch_dir and srv_log_archive_on #ifdef UNIV_LOG_ARCHIVE
innobase/include/sync0rw.ic:
Add const qualifier to string parameter
innobase/include/sync0sync.ic:
Add const qualifier to string parameter
innobase/log/log0log.c:
Enclose log archiving code in #ifdef UNIV_LOG_ARCHIVE
Do not cast string constants to (char*)
innobase/log/log0recv.c:
Enclose ibbackup specific code in #ifdef UNIV_HOTBACKUP
Enclose disabled log code in #ifdef UNIV_LOG_REPLICATE or UNIV_LOG_ARCHIVE
innobase/mem/mem0dbg.c:
Add const qualifiers to string parameters
innobase/page/page0page.c:
Remove (char*) casts of string constants
innobase/pars/pars0pars.c:
Add const qualifier to string variable
innobase/row/row0ins.c:
Remove (char*) casts of string constants
Add const qualifiers to string parameters
row_ins_foreign_check_on_constraint(): Allocate table_name dynamically
innobase/row/row0mysql.c:
Remove (char*) casts of string constants
innobase/row/row0sel.c:
Remove (char*) casts of string constants
innobase/srv/srv0srv.c:
Remove (char*) casts of string constants
Disable log archiving variables unless #ifdef UNIV_LOG_ARCHIVE
innobase/srv/srv0start.c:
Disable log archiving code unless #ifdef UNIV_LOG_ARCHIVE
Remove (char*) casts of string constants
innobase/sync/sync0rw.c:
Remove (char*) casts of string constants
Add const qualifier to string parameter
innobase/sync/sync0sync.c:
Remove (char*) cast of string constant
Add const qualifier to string parameter
innobase/trx/trx0roll.c:
Remove (char*) cast of string constants
innobase/trx/trx0sys.c:
Remove (char*) cast of string constants
innobase/trx/trx0trx.c:
Remove (char*) cast of string constant
sql/ha_innodb.cc:
Enclose log archiving code in #ifdef UNIV_LOG_ARCHIVE
Diffstat (limited to 'innobase/srv')
-rw-r--r-- | innobase/srv/srv0srv.c | 86 | ||||
-rw-r--r-- | innobase/srv/srv0start.c | 74 |
2 files changed, 89 insertions, 71 deletions
diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 33adcaa14b8..3817501ae70 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -57,7 +57,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*) ""; +const char* srv_main_thread_op_info = ""; /* Server parameters which are read from the initfile */ @@ -65,7 +65,9 @@ char* srv_main_thread_op_info = (char*) ""; names, where the file name itself may also contain a path */ char* srv_data_home = NULL; +#ifdef UNIV_LOG_ARCHIVE char* srv_arch_dir = NULL; +#endif /* UNIV_LOG_ARCHIVE */ ibool srv_file_per_table = FALSE; /* store to its own file each table created by an user; data dictionary @@ -94,7 +96,6 @@ char** srv_log_group_home_dirs = NULL; ulint srv_n_log_groups = ULINT_MAX; ulint srv_n_log_files = ULINT_MAX; ulint srv_log_file_size = ULINT_MAX; /* size in database pages */ -ibool srv_log_archive_on = FALSE; ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */ ulint srv_flush_log_at_trx_commit = 1; @@ -149,8 +150,11 @@ ulint srv_lock_table_size = ULINT_MAX; ulint srv_n_file_io_threads = ULINT_MAX; +#ifdef UNIV_LOG_ARCHIVE +ibool srv_log_archive_on = FALSE; ibool srv_archive_recovery = 0; dulint srv_archive_recovery_limit_lsn; +#endif /* UNIV_LOG_ARCHIVE */ ulint srv_lock_wait_timeout = 1024 * 1024 * 1024; @@ -921,11 +925,11 @@ retry: os_fast_mutex_unlock(&srv_conc_mutex); - trx->op_info = (char*)"sleeping before joining InnoDB queue"; + trx->op_info = "sleeping before joining InnoDB queue"; os_thread_sleep(50000); - trx->op_info = (char*)""; + trx->op_info = ""; os_fast_mutex_lock(&srv_conc_mutex); @@ -978,11 +982,11 @@ retry: /* Go to wait for the event; when a thread leaves InnoDB it will release this thread */ - trx->op_info = (char*)"waiting in InnoDB queue"; + trx->op_info = "waiting in InnoDB queue"; os_event_wait(slot->event); - trx->op_info = (char*)""; + trx->op_info = ""; os_fast_mutex_lock(&srv_conc_mutex); @@ -1946,7 +1950,7 @@ loop: /* ---- When there is database activity by users, we cycle in this loop */ - srv_main_thread_op_info = (char*) "reserving kernel mutex"; + srv_main_thread_op_info = "reserving kernel mutex"; n_ios_very_old = log_sys->n_log_ios + buf_pool->n_pages_read + buf_pool->n_pages_written; @@ -1970,7 +1974,7 @@ 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 = "sleeping"; if (!skip_sleep) { @@ -1983,12 +1987,11 @@ loop: 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 = "doing background drop tables"; row_drop_tables_for_mysql_in_background(); - srv_main_thread_op_info = (char*)""; + srv_main_thread_op_info = ""; if (srv_fast_shutdown && srv_shutdown_state > 0) { @@ -1999,10 +2002,10 @@ 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 = "flushing log"; log_buffer_flush_to_disk(); - srv_main_thread_op_info = (char*)"making checkpoint"; + srv_main_thread_op_info = "making checkpoint"; log_free_check(); /* If there were less than 5 i/os during the @@ -2015,11 +2018,10 @@ loop: n_ios = log_sys->n_log_ios + buf_pool->n_pages_read + buf_pool->n_pages_written; if (n_pend_ios < 3 && (n_ios - n_ios_old < 5)) { - srv_main_thread_op_info = - (char*)"doing insert buffer merge"; + srv_main_thread_op_info = "doing insert buffer merge"; ibuf_contract_for_n_pages(TRUE, 5); - srv_main_thread_op_info = (char*)"flushing log"; + srv_main_thread_op_info = "flushing log"; log_buffer_flush_to_disk(); } @@ -2067,20 +2069,20 @@ 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 = "flushing buffer pool pages"; buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max); - srv_main_thread_op_info = (char*) "flushing log"; + srv_main_thread_op_info = "flushing log"; log_buffer_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 = "doing insert buffer merge"; ibuf_contract_for_n_pages(TRUE, 5); - srv_main_thread_op_info = (char*)"flushing log"; + srv_main_thread_op_info = "flushing log"; log_buffer_flush_to_disk(); /* We run a full purge every 10 seconds, even if the server @@ -2097,20 +2099,20 @@ loop: goto background_loop; } - srv_main_thread_op_info = (char*)"purging"; + srv_main_thread_op_info = "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 = "flushing log"; log_buffer_flush_to_disk(); last_flush_time = current_time; } } - srv_main_thread_op_info = (char*)"flushing buffer pool pages"; + srv_main_thread_op_info = "flushing buffer pool pages"; /* Flush a few oldest pages to make a new checkpoint younger */ @@ -2131,13 +2133,13 @@ loop: ut_dulint_max); } - srv_main_thread_op_info = (char*)"making checkpoint"; + srv_main_thread_op_info = "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 = "reserving kernel mutex"; mutex_enter(&kernel_mutex); @@ -2161,7 +2163,7 @@ background_loop: /* The server has been quiet for a while: start running background operations */ - srv_main_thread_op_info = (char*)"doing background drop tables"; + srv_main_thread_op_info = "doing background drop tables"; n_tables_to_drop = row_drop_tables_for_mysql_in_background(); @@ -2174,7 +2176,7 @@ background_loop: os_thread_sleep(100000); } - srv_main_thread_op_info = (char*)"purging"; + srv_main_thread_op_info = "purging"; /* Run a full purge */ @@ -2188,20 +2190,20 @@ background_loop: break; } - srv_main_thread_op_info = (char*)"purging"; + srv_main_thread_op_info = "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 = "flushing log"; log_buffer_flush_to_disk(); last_flush_time = current_time; } } - srv_main_thread_op_info = (char*)"reserving kernel mutex"; + srv_main_thread_op_info = "reserving kernel mutex"; mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { @@ -2210,7 +2212,7 @@ background_loop: } mutex_exit(&kernel_mutex); - srv_main_thread_op_info = (char*)"doing insert buffer merge"; + srv_main_thread_op_info = "doing insert buffer merge"; if (srv_fast_shutdown && srv_shutdown_state > 0) { n_bytes_merged = 0; @@ -2218,7 +2220,7 @@ background_loop: n_bytes_merged = ibuf_contract_for_n_pages(TRUE, 20); } - srv_main_thread_op_info = (char*)"reserving kernel mutex"; + srv_main_thread_op_info = "reserving kernel mutex"; mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { @@ -2228,10 +2230,10 @@ background_loop: mutex_exit(&kernel_mutex); flush_loop: - srv_main_thread_op_info = (char*)"flushing buffer pool pages"; + srv_main_thread_op_info = "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 = "reserving kernel mutex"; mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { @@ -2240,15 +2242,14 @@ flush_loop: } mutex_exit(&kernel_mutex); - srv_main_thread_op_info = - (char*) "waiting for buffer pool flush to end"; + srv_main_thread_op_info = "waiting for buffer pool flush to end"; buf_flush_wait_batch_end(BUF_FLUSH_LIST); - srv_main_thread_op_info = (char*) "flushing log"; + srv_main_thread_op_info = "flushing log"; log_buffer_flush_to_disk(); - srv_main_thread_op_info = (char*)"making checkpoint"; + srv_main_thread_op_info = "making checkpoint"; log_checkpoint(TRUE, FALSE); @@ -2260,7 +2261,7 @@ flush_loop: goto flush_loop; } - srv_main_thread_op_info = (char*)"reserving kernel mutex"; + srv_main_thread_op_info = "reserving kernel mutex"; mutex_enter(&kernel_mutex); if (srv_activity_count != old_activity_count) { @@ -2269,8 +2270,7 @@ flush_loop: } mutex_exit(&kernel_mutex); /* - srv_main_thread_op_info = - (char*)"archiving log (if log archive is on)"; + srv_main_thread_op_info = "archiving log (if log archive is on)"; log_archive_do(FALSE, &n_bytes_archived); */ @@ -2301,7 +2301,7 @@ flush_loop: master thread to wait for more server activity */ suspend_thread: - srv_main_thread_op_info = (char*)"suspending"; + srv_main_thread_op_info = "suspending"; mutex_enter(&kernel_mutex); @@ -2315,7 +2315,7 @@ suspend_thread: mutex_exit(&kernel_mutex); - srv_main_thread_op_info = (char*)"waiting for server activity"; + srv_main_thread_op_info = "waiting for server activity"; os_event_wait(event); diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 68fcb82c6d8..3bf39e6422b 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -628,7 +628,7 @@ open_or_create_log_file( fil_node_create(name, srv_log_file_size, 2 * k + SRV_LOG_SPACE_FIRST_ID, FALSE); -#ifdef notdefined +#ifdef UNIV_LOG_ARCHIVE /* If this is the first log group, create the file space object for archived logs. Under MySQL, no archiving ever done. */ @@ -636,12 +636,11 @@ 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("arch_log_space", arch_space_id, FIL_LOG); } else { arch_space_id = ULINT_UNDEFINED; } -#endif +#endif /* UNIV_LOG_ARCHIVE */ if (i == 0) { log_group_init(k, srv_n_log_files, srv_log_file_size * UNIV_PAGE_SIZE, @@ -662,12 +661,14 @@ open_or_create_data_files( /* out: DB_SUCCESS or error code */ ibool* create_new_db, /* out: TRUE if new database should be created */ - dulint* min_flushed_lsn,/* out: min of flushed lsn values in data - files */ +#ifdef UNIV_LOG_ARCHIVE ulint* min_arch_log_no,/* out: min of archived log numbers in data files */ - dulint* max_flushed_lsn,/* out: */ ulint* max_arch_log_no,/* out: */ +#endif /* UNIV_LOG_ARCHIVE */ + dulint* min_flushed_lsn,/* out: min of flushed lsn values in data + files */ + dulint* max_flushed_lsn,/* out: */ ulint* sum_of_new_sizes)/* out: sum of sizes of the new files added */ { ibool ret; @@ -820,8 +821,10 @@ open_or_create_data_files( skip_size_check: fil_read_flushed_lsn_and_arch_log_no(files[i], one_opened, - min_flushed_lsn, min_arch_log_no, - max_flushed_lsn, max_arch_log_no); +#ifdef UNIV_LOG_ARCHIVE + min_arch_log_no, max_arch_log_no, +#endif /* UNIV_LOG_ARCHIVE */ + min_flushed_lsn, max_flushed_lsn); one_opened = TRUE; } else { /* We created the data file and now write it full of @@ -908,8 +911,10 @@ innobase_start_or_create_for_mysql(void) ibool log_opened = FALSE; dulint min_flushed_lsn; dulint max_flushed_lsn; +#ifdef UNIV_LOG_ARCHIVE ulint min_arch_log_no; ulint max_arch_log_no; +#endif /* UNIV_LOG_ARCHIVE */ ulint sum_of_new_sizes; ulint sum_of_data_file_sizes; ulint tablespace_size_in_header; @@ -1017,28 +1022,22 @@ innobase_start_or_create_for_mysql(void) srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED; #ifndef __WIN__ - } else if (0 == ut_strcmp(srv_file_flush_method_str, - (char*)"fdatasync")) { + } else if (0 == ut_strcmp(srv_file_flush_method_str, "fdatasync")) { srv_unix_file_flush_method = SRV_UNIX_FDATASYNC; - } else if (0 == ut_strcmp(srv_file_flush_method_str, - (char*)"O_DSYNC")) { + } else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DSYNC")) { srv_unix_file_flush_method = SRV_UNIX_O_DSYNC; - } else if (0 == ut_strcmp(srv_file_flush_method_str, - (char*)"O_DIRECT")) { + } else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DIRECT")) { srv_unix_file_flush_method = SRV_UNIX_O_DIRECT; - } else if (0 == ut_strcmp(srv_file_flush_method_str, - (char*)"littlesync")) { + } else if (0 == ut_strcmp(srv_file_flush_method_str, "littlesync")) { srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC; - } else if (0 == ut_strcmp(srv_file_flush_method_str, - (char*)"nosync")) { + } else if (0 == ut_strcmp(srv_file_flush_method_str, "nosync")) { srv_unix_file_flush_method = SRV_UNIX_NOSYNC; #else - } else if (0 == ut_strcmp(srv_file_flush_method_str, - (char*)"normal")) { + } else if (0 == ut_strcmp(srv_file_flush_method_str, "normal")) { srv_win_file_flush_method = SRV_WIN_IO_NORMAL; os_aio_use_native_aio = FALSE; @@ -1181,6 +1180,7 @@ NetWare. */ os_thread_create(io_handler_thread, n + i, thread_ids + i); } +#ifdef UNIV_LOG_ARCHIVE if (0 != ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) { fprintf(stderr, "InnoDB: Error: you must set the log group home dir in my.cnf the\n" @@ -1188,6 +1188,7 @@ NetWare. */ return(DB_ERROR); } +#endif /* UNIV_LOG_ARCHIVE */ if (srv_n_log_files * srv_log_file_size >= 262144) { fprintf(stderr, @@ -1219,8 +1220,10 @@ NetWare. */ } err = open_or_create_data_files(&create_new_db, - &min_flushed_lsn, &min_arch_log_no, - &max_flushed_lsn, &max_arch_log_no, +#ifdef UNIV_LOG_ARCHIVE + &min_arch_log_no, &max_arch_log_no, +#endif /* UNIV_LOG_ARCHIVE */ + &min_flushed_lsn, &max_flushed_lsn, &sum_of_new_sizes); if (err != DB_SUCCESS) { fprintf(stderr, @@ -1235,8 +1238,10 @@ NetWare. */ return((int) err); } +#ifdef UNIV_LOG_ARCHIVE srv_normalize_path_for_win(srv_arch_dir); srv_arch_dir = srv_add_path_separator_if_needed(srv_arch_dir); +#endif /* UNIV_LOG_ARCHIVE */ for (i = 0; i < srv_n_log_files; i++) { err = open_or_create_log_file(create_new_db, &log_file_created, @@ -1270,9 +1275,16 @@ NetWare. */ fil_open_log_and_system_tablespace_files(); - if (log_created && !create_new_db && !srv_archive_recovery) { + if (log_created && !create_new_db +#ifdef UNIV_LOG_ARCHIVE + && !srv_archive_recovery +#endif /* UNIV_LOG_ARCHIVE */ + ) { if (ut_dulint_cmp(max_flushed_lsn, min_flushed_lsn) != 0 - || max_arch_log_no != min_arch_log_no) { +#ifdef UNIV_LOG_ARCHIVE + || max_arch_log_no != min_arch_log_no +#endif /* UNIV_LOG_ARCHIVE */ + ) { fprintf(stderr, "InnoDB: Cannot initialize created log files because\n" "InnoDB: data files were not in sync with each other\n" @@ -1295,10 +1307,14 @@ NetWare. */ mutex_enter(&(log_sys->mutex)); +#ifdef UNIV_LOG_ARCHIVE /* Do not + 1 arch_log_no because we do not use log archiving */ recv_reset_logs(max_flushed_lsn, max_arch_log_no, TRUE); - +#else + recv_reset_logs(max_flushed_lsn, TRUE); +#endif /* UNIV_LOG_ARCHIVE */ + mutex_exit(&(log_sys->mutex)); } @@ -1313,6 +1329,7 @@ NetWare. */ dict_create(); srv_startup_is_before_trx_rollback_phase = FALSE; +#ifdef UNIV_LOG_ARCHIVE } else if (srv_archive_recovery) { fprintf(stderr, "InnoDB: Starting archive recovery from a backup...\n"); @@ -1336,6 +1353,7 @@ NetWare. */ fsp_header_get_free_limit(0); recv_recovery_from_archive_finish(); +#endif /* UNIV_LOG_ARCHIVE */ } else { /* We always try to do a recovery, even if the database had been shut down normally: this is the normal startup path */ @@ -1384,7 +1402,7 @@ NetWare. */ log_make_checkpoint_at(ut_dulint_max, TRUE); -#ifdef notdefined +#ifdef UNIV_LOG_ARCHIVE /* Archiving is always off under MySQL */ if (!srv_log_archive_on) { ut_a(DB_SUCCESS == log_archive_noarchivelog()); @@ -1403,7 +1421,7 @@ NetWare. */ ut_a(DB_SUCCESS == log_archive_archivelog()); } } -#endif +#endif /* UNIV_LOG_ARCHIVE */ if (!create_new_db && srv_force_recovery == 0) { /* After a crash recovery we only check that the info in data dictionary is consistent with what we already know about space |