函数innobase_start_or_create_for_mysql
buffer pool初始化
/******************************************************************** Starts InnoDB and creates a new database if database files are not found and the user wants. @return DB_SUCCESS or error code */ UNIV_INTERN int innobase_start_or_create_for_mysql(void) /*====================================*/ { ibool create_new_db; ibool log_file_created; ibool log_created = FALSE; ibool log_opened = FALSE; ib_uint64_t min_flushed_lsn; ib_uint64_t 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; ulint err; ulint i; ulint io_limit; my_bool srv_file_per_table_original_value = srv_file_per_table; mtr_t mtr; #ifdef HAVE_DARWIN_THREADS # ifdef F_FULLFSYNC /* This executable has been compiled on Mac OS X 10.3 or later. Assume that F_FULLFSYNC is available at run-time. */ srv_have_fullfsync = TRUE; # else /* F_FULLFSYNC */ /* This executable has been compiled on Mac OS X 10.2 or earlier. Determine if the executable is running on Mac OS X 10.3 or later. */ struct utsname utsname; if (uname(&utsname)) { ut_print_timestamp(stderr); fputs(" InnoDB: cannot determine Mac OS X version!\n", stderr); } else { srv_have_fullfsync = strcmp(utsname.release, ; } if (!srv_have_fullfsync) { ut_print_timestamp(stderr); fputs(" InnoDB: On Mac OS X, fsync() may be " "broken on internal drives,\n", stderr); ut_print_timestamp(stderr); fputs(" InnoDB: making transactions unsafe!\n", stderr); } # endif /* F_FULLFSYNC */ #endif /* HAVE_DARWIN_THREADS */ if (sizeof(ulint) != sizeof(void*)) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: size of InnoDB's ulint is %lu, " "but size of void*\n", (ulong) sizeof(ulint)); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: is %lu. The sizes should be the same " "so that on a 64-bit\n", (ulong) sizeof(void*)); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: platforms you can allocate more than 4 GB " "of memory.\n"); } /* System tables are created in tablespace 0. Thus, we must temporarily clear srv_file_per_table. This is ok, because the server will not accept connections (which could modify innodb_file_per_table) until this function has returned. */ srv_file_per_table = FALSE; #ifdef UNIV_DEBUG ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n"); #endif #ifdef UNIV_IBUF_DEBUG ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: !!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!\n"); # ifdef UNIV_IBUF_COUNT_DEBUG ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: !!!!!!!! UNIV_IBUF_COUNT_DEBUG switched on " "!!!!!!!!!\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Crash recovery will fail with UNIV_IBUF_COUNT_DEBUG\n"); # endif #endif #ifdef UNIV_BLOB_DEBUG fprintf(stderr, "InnoDB: !!!!!!!! UNIV_BLOB_DEBUG switched on !!!!!!!!!\n" "InnoDB: Server restart may fail with UNIV_BLOB_DEBUG\n"); #endif /* UNIV_BLOB_DEBUG */ #ifdef UNIV_SYNC_DEBUG ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n"); #endif #ifdef UNIV_SEARCH_DEBUG ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n"); #endif #ifdef UNIV_LOG_LSN_DEBUG ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: !!!!!!!! UNIV_LOG_LSN_DEBUG switched on !!!!!!!!!\n"); #endif /* UNIV_LOG_LSN_DEBUG */ #ifdef UNIV_MEM_DEBUG ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n"); #endif if (UNIV_LIKELY(srv_use_sys_malloc)) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: The InnoDB memory heap is disabled\n"); } ut_print_timestamp(stderr); fputs(" InnoDB: " IB_ATOMICS_STARTUP_MSG "\n", stderr); ut_print_timestamp(stderr); fputs(" InnoDB: Compressed tables use zlib " ZLIB_VERSION #ifdef UNIV_ZIP_DEBUG " with validation" #endif /* UNIV_ZIP_DEBUG */ "\n" , stderr); #ifdef UNIV_ZIP_COPY ut_print_timestamp(stderr); fputs(" InnoDB: and extra copying\n", stderr); #endif /* UNIV_ZIP_COPY */ /* Since InnoDB does not currently clean up all its internal data structures in MySQL Embedded Server Library server_end(), we print an error message if someone tries to start up InnoDB a second time during the process lifetime. */ if (srv_start_has_been_called) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: startup called second time " "during the process\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: lifetime. In the MySQL Embedded " "Server Library you\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: cannot call server_init() more " "than once during the\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: process lifetime.\n"); } srv_start_has_been_called = TRUE; #ifdef UNIV_DEBUG log_do_write = TRUE; #endif /* UNIV_DEBUG */ /* yydebug = TRUE; */ srv_is_being_started = TRUE; srv_startup_is_before_trx_rollback_phase = TRUE; #ifdef __WIN__ switch (os_get_os_version()) { case OS_WIN95: case OS_WIN31: case OS_WINNT: /* On Win 95, 98, ME, Win32 subsystem for Windows 3.1, and NT use simulated aio. In NT Windows provides async i/o, but when run in conjunction with InnoDB Hot Backup, it seemed to corrupt the data files. */ srv_use_native_aio = FALSE; break; case OS_WIN2000: case OS_WINXP: /* On 2000 and XP, async IO is available. */ srv_use_native_aio = TRUE; break; default: /* Vista and later have both async IO and condition variables */ srv_use_native_aio = TRUE; srv_use_native_conditions = TRUE; break; } #elif defined(LINUX_NATIVE_AIO) if (srv_use_native_aio) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Using Linux native AIO\n"); } #else /* Currently native AIO is supported only on windows and linux and that also when the support is compiled in. In all other cases, we ignore the setting of innodb_use_native_aio. */ srv_use_native_aio = FALSE; #endif if (srv_file_flush_method_str == NULL) { /* These are the default options */ srv_unix_file_flush_method = SRV_UNIX_FSYNC; srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED; #ifndef __WIN__ } == ut_strcmp(srv_file_flush_method_str, "fsync")) { srv_unix_file_flush_method = SRV_UNIX_FSYNC; } == ut_strcmp(srv_file_flush_method_str, "O_DSYNC")) { srv_unix_file_flush_method = SRV_UNIX_O_DSYNC; } == ut_strcmp(srv_file_flush_method_str, "O_DIRECT")) { srv_unix_file_flush_method = SRV_UNIX_O_DIRECT; } == ut_strcmp(srv_file_flush_method_str, "littlesync")) { srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC; } == ut_strcmp(srv_file_flush_method_str, "nosync")) { srv_unix_file_flush_method = SRV_UNIX_NOSYNC; #else } == ut_strcmp(srv_file_flush_method_str, "normal")) { srv_win_file_flush_method = SRV_WIN_IO_NORMAL; srv_use_native_aio = FALSE; } == ut_strcmp(srv_file_flush_method_str, "unbuffered")) { srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED; srv_use_native_aio = FALSE; } == ut_strcmp(srv_file_flush_method_str, "async_unbuffered")) { srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED; #endif } else { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Unrecognized value %s for" " innodb_flush_method\n", srv_file_flush_method_str); return(DB_ERROR); } /* Note that the call srv_boot() also changes the values of some variables to the units used by InnoDB internally */ /* Set the maximum number of threads which can wait for a semaphore inside InnoDB: this is the 'sync wait array' size, as well as the maximum number of threads that can wait in the 'srv_conc array' for their time to enter InnoDB. */ * * ) { /* If buffer pool is less than 1000 MB, assume fewer threads. Also use only one buffer pool instance */ srv_max_n_threads = ; } * * ) { srv_buf_pool_instances = ; srv_max_n_threads = ; } else { srv_buf_pool_instances = ; srv_max_n_threads = ; /* saves several MB of memory, especially in 64-bit computers */ } err = srv_boot(); if (err != DB_SUCCESS) { return((int) err); } mutex_create(srv_monitor_file_mutex_key, &srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK); if (srv_innodb_status) { srv_monitor_file_name = mem_alloc( strlen(fil_path_to_mysql_datadir) + + sizeof "/innodb_status."); sprintf(srv_monitor_file_name, "%s/innodb_status.%lu", fil_path_to_mysql_datadir, os_proc_get_number()); srv_monitor_file = fopen(srv_monitor_file_name, "w+"); if (!srv_monitor_file) { fprintf(stderr, "InnoDB: unable to create %s: %s\n", srv_monitor_file_name, strerror(errno)); return(DB_ERROR); } } else { srv_monitor_file_name = NULL; srv_monitor_file = os_file_create_tmpfile(); if (!srv_monitor_file) { return(DB_ERROR); } } mutex_create(srv_dict_tmpfile_mutex_key, &srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION); srv_dict_tmpfile = os_file_create_tmpfile(); if (!srv_dict_tmpfile) { return(DB_ERROR); } mutex_create(srv_misc_tmpfile_mutex_key, &srv_misc_tmpfile_mutex, SYNC_ANY_LATCH); srv_misc_tmpfile = os_file_create_tmpfile(); if (!srv_misc_tmpfile) { return(DB_ERROR); } /* If user has set the value of innodb_file_io_threads then we'll emit a message telling the user that this parameter is now deprecated. */ ) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Warning:" " innodb_file_io_threads is deprecated." " Please use innodb_read_io_threads and" " innodb_write_io_threads instead\n"); } /* Now overwrite the value on srv_n_file_io_threads */ srv_n_file_io_threads = + srv_n_read_io_threads + srv_n_write_io_threads; ut_a(srv_n_file_io_threads <= SRV_MAX_N_IO_THREADS); io_limit = * SRV_N_PENDING_IOS_PER_THREAD; if (!os_aio_init(io_limit, srv_n_read_io_threads, srv_n_write_io_threads, SRV_MAX_N_PENDING_SYNC_IOS)) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Fatal error: cannot initialize AIO" " sub-system\n"); return(DB_ERROR); } fil_init(srv_file_per_table ? : ,srv_max_n_open_files); /** *UNIV_INTERN ulint srv_buf_pool_size = ULINT_MAX; *#define ULINT_MAX ((ulint)(-2)) *如果是32位的无符号长整型的话,其内存值应该是0xFFFFFFFE 值为4294967294 约4G内存 *unsight long int * *UNIV_INTERN ulint srv_buf_pool_instances = 1;//requested number of buffer pool instances
*/ err = buf_pool_init(srv_buf_pool_size, srv_buf_pool_instances); //buf_pool_init 初始化 详见 fprintf(stderr," InnoDB: Completed initialization of buffer pool\n"); if (err != DB_SUCCESS) { fprintf(stderr," InnoDB: Fatal error: cannot allocate memory" " for the buffer pool\n"); return(DB_ERROR); } fsp_init(); log_init(); lock_sys_create(srv_lock_table_size); /* Create i/o-handler threads: */ ; i < srv_n_file_io_threads; i++) { n[i] = i; os_thread_create(io_handler_thread, n + i, thread_ids + i); } ) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: combined size of log files" " must be < 4 GB\n"); return(DB_ERROR); } sum_of_new_sizes = ; / UNIV_PAGE_SIZE) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: tablespace size must be" " at least 10 MB\n"); return(DB_ERROR); } err = open_or_create_data_files(&create_new_db, #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) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Could not open or create data files.\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: If you tried to add new data files," " and it failed here,\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: you should now edit innodb_data_file_path" " in my.cnf back\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: to what it was, and remove the" " new ibdata files InnoDB created\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: in this failed attempt. InnoDB only wrote" " those files full of\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: zeros, but did not yet use them in any way." " But be careful: do not\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: remove old data files" " which contain your precious data!\n"); return((int) err); } ; i < srv_n_log_files; i++) { err = open_or_create_log_file(create_new_db, &log_file_created, log_opened, , i); if (err != DB_SUCCESS) { return((int) err); } if (log_file_created) { log_created = TRUE; } else { log_opened = TRUE; } if ((log_opened && create_new_db) || (log_opened && log_created)) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: all log files must be" " created at the same time.\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: All log files must be" " created also in database creation.\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: If you want bigger or smaller" " log files, shut down the\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: database and make sure there" " were no errors in shutdown.\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Then delete the existing log files." " Edit the .cnf file\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: and start the database again.\n"); return(DB_ERROR); } } /* Open all log files and data files in the system tablespace: we keep them open until database shutdown */ fil_open_log_and_system_tablespace_files(); if (log_created && !create_new_db #ifdef UNIV_LOG_ARCHIVE && !srv_archive_recovery #endif /* UNIV_LOG_ARCHIVE */ ) { if (max_flushed_lsn != min_flushed_lsn #ifdef UNIV_LOG_ARCHIVE || max_arch_log_no != min_arch_log_no #endif /* UNIV_LOG_ARCHIVE */ ) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Cannot initialize created" " log files because\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: data files were not in sync" " with each other\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: or the data files are corrupt.\n"); return(DB_ERROR); } ) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Cannot initialize created" " log files because\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: data files are corrupt," " or new data files were\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: created when the database" " was started previous\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: time but the database" " was not shut down\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: normally after that.\n"); return(DB_ERROR); } 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)); } trx_sys_file_format_init(); if (create_new_db) { mtr_start(&mtr); fsp_header_init(, sum_of_new_sizes, &mtr); mtr_commit(&mtr); /* To maintain backward compatibility we create only the first rollback segment before the double write buffer. All the remaining rollback segments will be created later, after the double write buffer has been created. */ trx_sys_create(); dict_create(); srv_startup_is_before_trx_rollback_phase = FALSE; #ifdef UNIV_LOG_ARCHIVE } else if (srv_archive_recovery) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Starting archive" " recovery from a backup...\n"); err = recv_recovery_from_archive_start( min_flushed_lsn, srv_archive_recovery_limit_lsn, min_arch_log_no); if (err != DB_SUCCESS) { return(DB_ERROR); } /* Since ibuf init is in dict_boot, and ibuf is needed in any disk i/o, first call dict_boot */ dict_boot(); trx_sys_init_at_db_start(); srv_startup_is_before_trx_rollback_phase = FALSE; /* Initialize the fsp free limit global variable in the log system */ fsp_header_get_free_limit(); recv_recovery_from_archive_finish(); #endif /* UNIV_LOG_ARCHIVE */ } else { /* Check if we support the max format that is stamped on the system tablespace. Note: We are NOT allowed to make any modifications to the TRX_SYS_PAGE_NO page before recovery because this page also contains the max_trx_id etc. important system variables that are required for recovery. We need to ensure that we return the system to a state where normal recovery is guaranteed to work. We do this by invalidating the buffer cache, this will force the reread of the page and restoration to its last known consistent state, this is REQUIRED for the recovery process to work. */ err = trx_sys_file_format_max_check( srv_max_file_format_at_startup); if (err != DB_SUCCESS) { return(err); } /* Invalidate the buffer pool to ensure that we reread the page that we read above, during recovery. Note that this is not as heavy weight as it seems. At this point there will be only ONE page in the buf_LRU and there must be no page in the buf_flush list. */ buf_pool_invalidate(); /* We always try to do a recovery, even if the database had been shut down normally: this is the normal startup path */ err = recv_recovery_from_checkpoint_start(LOG_CHECKPOINT, IB_ULONGLONG_MAX, min_flushed_lsn, max_flushed_lsn); if (err != DB_SUCCESS) { return(DB_ERROR); } /* Since the insert buffer init is in dict_boot, and the insert buffer is needed in any disk i/o, first we call dict_boot(). Note that trx_sys_init_at_db_start() only needs to access space 0, and the insert buffer at this stage already works for space 0. */ dict_boot(); trx_sys_init_at_db_start(); /* Initialize the fsp free limit global variable in the log system */ fsp_header_get_free_limit(); /* recv_recovery_from_checkpoint_finish needs trx lists which are initialized in trx_sys_init_at_db_start(). */ recv_recovery_from_checkpoint_finish(); if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) { /* The following call is necessary for the insert buffer to work with multiple tablespaces. We must know the mapping between space id's and .ibd file names. In a crash recovery, we check that the info in data dictionary is consistent with what we already know about space id's from the call of fil_load_single_table_tablespaces(). In a normal startup, we create the space objects for every table in the InnoDB data dictionary that has an .ibd file. We also determine the maximum tablespace id used. */ dict_check_tablespaces_and_store_max_id( recv_needed_recovery); } srv_startup_is_before_trx_rollback_phase = FALSE; recv_recovery_rollback_active(); /* It is possible that file_format tag has never been set. In this case we initialize it to minimum value. Important to note that we can do it ONLY after we have finished the recovery process so that the image of TRX_SYS_PAGE_NO is not stale. */ trx_sys_file_format_tag_init(); } ) { /* New data file(s) were added */ mtr_start(&mtr); fsp_header_inc_size(, sum_of_new_sizes, &mtr); mtr_commit(&mtr); /* Immediately write the log record about increased tablespace size to disk, so that it is durable even if mysqld would crash quickly */ log_buffer_flush_to_disk(); } #ifdef UNIV_LOG_ARCHIVE /* Archiving is always off under MySQL */ if (!srv_log_archive_on) { ut_a(DB_SUCCESS == log_archive_noarchivelog()); } else { mutex_enter(&(log_sys->mutex)); start_archive = FALSE; if (log_sys->archiving_state == LOG_ARCH_OFF) { start_archive = TRUE; } mutex_exit(&(log_sys->mutex)); if (start_archive) { ut_a(DB_SUCCESS == log_archive_archivelog()); } } #endif /* UNIV_LOG_ARCHIVE */ /* fprintf(stderr, "Max allowed record size %lu\n", page_get_free_space_of_empty() / 2); */ if (trx_doublewrite == NULL) { /* Create the doublewrite buffer to a new tablespace */ trx_sys_create_doublewrite_buf(); } /* Here the double write buffer has already been created and so any new rollback segments will be allocated after the double write buffer. The default segment should already exist. We create the new segments only if it's a new database or the database was shutdown cleanly. */ /* Note: When creating the extra rollback segments during an upgrade we violate the latching order, even if the change buffer is empty. We make an exception in sync0sync.c and check srv_is_being_started for that violation. It cannot create a deadlock because we are still running in single threaded mode essentially. Only the IO threads should be running at this stage. */ trx_sys_create_rsegs(TRX_SYS_N_RSEGS - ); /* Create the thread which watches the timeouts for lock waits */ os_thread_create(&srv_lock_timeout_thread, NULL, thread_ids + + SRV_MAX_N_IO_THREADS); /* Create the thread which warns of long semaphore waits */ os_thread_create(&srv_error_monitor_thread, NULL, thread_ids + + SRV_MAX_N_IO_THREADS); /* Create the thread which prints InnoDB monitor info */ os_thread_create(&srv_monitor_thread, NULL, thread_ids + + SRV_MAX_N_IO_THREADS); srv_is_being_started = FALSE; err = dict_create_or_check_foreign_constraint_tables(); if (err != DB_SUCCESS) { return((int)DB_ERROR); } /* Create the master thread which does purge and other utility operations */ os_thread_create(&srv_master_thread, NULL, thread_ids + ( + SRV_MAX_N_IO_THREADS)); /* Currently we allow only a single purge thread. */ ut_a(srv_n_purge_threads == || srv_n_purge_threads == ); /* If the user has requested a separate purge thread then start the purge thread. */ ) { os_thread_create(&srv_purge_thread, NULL, NULL); } /* Wait for the purge and master thread to startup. */ while (srv_shutdown_state == SRV_SHUTDOWN_NONE) { if (srv_thread_has_reserved_slot(SRV_MASTER) == ULINT_UNDEFINED || (srv_n_purge_threads == && srv_thread_has_reserved_slot(SRV_WORKER) == ULINT_UNDEFINED)) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: " "Waiting for the background threads to " "start\n"); os_thread_sleep(); } else { break; } } #ifdef UNIV_DEBUG /* buf_debug_prints = TRUE; */ #endif /* UNIV_DEBUG */ sum_of_data_file_sizes = ; ; i < srv_n_data_files; i++) { sum_of_data_file_sizes += srv_data_file_sizes[i]; } tablespace_size_in_header = fsp_header_get_tablespace_size(); if (!srv_auto_extend_last_data_file && sum_of_data_file_sizes != tablespace_size_in_header) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: tablespace size" " stored in header is %lu pages, but\n", (ulong) tablespace_size_in_header); ut_print_timestamp(stderr); fprintf(stderr, "InnoDB: the sum of data file sizes is %lu pages\n", (ulong) sum_of_data_file_sizes); && sum_of_data_file_sizes < tablespace_size_in_header) { /* This is a fatal error, the tail of a tablespace is missing */ ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Cannot start InnoDB." " The tail of the system tablespace is\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: missing. Have you edited" " innodb_data_file_path in my.cnf in an\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: inappropriate way, removing" " ibdata files from there?\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: You can set innodb_force_recovery=1" " in my.cnf to force\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: a startup if you are trying" " to recover a badly corrupt database.\n"); return(DB_ERROR); } } if (srv_auto_extend_last_data_file && sum_of_data_file_sizes < tablespace_size_in_header) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: tablespace size stored in header" " is %lu pages, but\n", (ulong) tablespace_size_in_header); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: the sum of data file sizes" " is only %lu pages\n", (ulong) sum_of_data_file_sizes); ) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Cannot start InnoDB. The tail of" " the system tablespace is\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: missing. Have you edited" " innodb_data_file_path in my.cnf in an\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: inappropriate way, removing" " ibdata files from there?\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: You can set innodb_force_recovery=1" " in my.cnf to force\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: a startup if you are trying to" " recover a badly corrupt database.\n"); return(DB_ERROR); } } /* Check that os_fast_mutexes work as expected */ os_fast_mutex_init(&srv_os_test_mutex); != os_fast_mutex_trylock(&srv_os_test_mutex)) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: pthread_mutex_trylock returns" " an unexpected value on\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: success! Cannot continue.\n"); exit(); } os_fast_mutex_unlock(&srv_os_test_mutex); os_fast_mutex_lock(&srv_os_test_mutex); os_fast_mutex_unlock(&srv_os_test_mutex); os_fast_mutex_free(&srv_os_test_mutex); if (srv_print_verbose_log) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: %s started; " "log sequence number %llu\n", INNODB_VERSION_STR, srv_start_lsn); } ) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: !!! innodb_force_recovery" " is set to %lu !!!\n", (ulong) srv_force_recovery); } fflush(stderr); if (trx_doublewrite_must_reset_space_ids) { /* Actually, we did not change the undo log format between 4.0 and 4.1.1, and we would not need to run purge to completion. Note also that the purge algorithm in 4.1.1 can process the history list again even after a full purge, because our algorithm does not cut the end of the history list in all cases so that it would become empty after a full purge. That mean that we may purge 4.0 type undo log even after this phase. The insert buffer record format changed between 4.0 and 4.1.1. It is essential that the insert buffer is emptied here! */ ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: You are upgrading to an" " InnoDB version which allows multiple\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: tablespaces. Wait that purge" " and insert buffer merge run to\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: completion...\n"); for (;;) { os_thread_sleep(); == strcmp(srv_main_thread_op_info, "waiting for server activity")) { ut_a(ibuf_is_empty()); break; } } ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Full purge and insert buffer merge" " completed.\n"); trx_sys_mark_upgraded_to_multiple_tablespaces(); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: You have now successfully upgraded" " to the multiple tablespaces\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: format. You should NOT DOWNGRADE" " to an earlier version of\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: InnoDB! But if you absolutely need to" " downgrade, see\n"); ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: " REFMAN "multiple-tablespaces.html\n" " InnoDB: for instructions.\n"); } ) { /* In the insert buffer we may have even bigger tablespace id's, because we may have dropped those tablespaces, but insert buffer merge has not had time to clean the records from the ibuf tree. */ ibuf_update_max_tablespace_id(); } srv_file_per_table = srv_file_per_table_original_value; srv_was_started = TRUE; return((int) DB_SUCCESS); }
函数innobase_start_or_create_for_mysql的更多相关文章
- MySQL之Innodb恢复的学习笔记
MySQL · 引擎特性 · InnoDB 崩溃恢复过程 enum { SRV_FORCE_IGNORE_CORRUPT = 1, /*!< let the server run even if ...
- Mysql源码学习——Thread Manager
一.前言 上篇的Connection Manager中,曾提及对于一个新到来的Connection,服务器会创建一个新的线程来处理这个连接. 其实没那么简单,为了提高系统效率,减少频繁创建线程和中止线 ...
- Python 小而美的函数
python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况 any any(iterable) ...
- 探究javascript对象和数组的异同,及函数变量缓存技巧
javascript中最经典也最受非议的一句话就是:javascript中一切皆是对象.这篇重点要提到的,就是任何jser都不陌生的Object和Array. 有段时间曾经很诧异,到底两种数据类型用来 ...
- JavaScript权威指南 - 函数
函数本身就是一段JavaScript代码,定义一次但可能被调用任意次.如果函数挂载在一个对象上,作为对象的一个属性,通常这种函数被称作对象的方法.用于初始化一个新创建的对象的函数被称作构造函数. 相对 ...
- C++对C的函数拓展
一,内联函数 1.内联函数的概念 C++中的const常量可以用来代替宏常数的定义,例如:用const int a = 10来替换# define a 10.那么C++中是否有什么解决方案来替代宏代码 ...
- 菜鸟Python学习笔记第一天:关于一些函数库的使用
2017年1月3日 星期二 大一学习一门新的计算机语言真的很难,有时候连函数拼写出错查错都能查半天,没办法,谁让我英语太渣. 关于计算机语言的学习我想还是从C语言学习开始为好,Python有很多语言的 ...
- javascript中的this与函数讲解
前言 javascript中没有块级作用域(es6以前),javascript中作用域分为函数作用域和全局作用域.并且,大家可以认为全局作用域其实就是Window函数的函数作用域,我们编写的js代码, ...
- 复杂的 Hash 函数组合有意义吗?
很久以前看到一篇文章,讲某个大网站储存用户口令时,会经过十分复杂的处理.怎么个复杂记不得了,大概就是先 Hash,结果加上一些特殊字符再 Hash,结果再加上些字符.再倒序.再怎么怎么的.再 Hash ...
随机推荐
- Scrapy简介
什么是Scrapy? Scrapy是一个快速.高级的爬行器和网页抓取框架,用来抓取网站和提取网页中结构化的数据.它被广泛的使用于监控数据采集和自动化测试. 参考:http://scrapy.org/
- 常用mysql命令大全
常用的MySQL命令大全 一.连接MySQL 格式: mysql -h主机地址 -u用户名 -p用户密码 1.例1:连接到本机上的MYSQL. 首先在打开DOS窗口,然后进入目录 mysqlbin,再 ...
- php5 图片验证码一例
php5 图片验证码. GD库的函数1,imagecreatetruecolor -----创建一个真彩色的图像imagecreatetruecolor(int x_size,int y_size) ...
- hdu 4622 Reincarnation 字符串hash 模板题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4622 题意:给定一个长度不超过2000的字符串,之后有不超过1e5次的区间查询,输出每次查询区间中不同 ...
- Weblogic12c安装与配置详解
Weblogic是什么Weblogic的安装Weblogic创建域Weblogic管理域Weblogic的应用Weblogic是什么 Weblogic这是我入职以后第一次接触到的词汇,我很陌生,就从我 ...
- iOS 支付宝应用(备用参考2)
接入前期准备工作包括商户签约和密钥配置 步骤1: 启动IDE(如Xcode),把iOS包中的压缩文件中以下文件拷贝到项目文件夹下, 并导入到项目工程中. AlipaySDK.bundle Al ...
- JS、C# 去除html标签
JS去除html标签 var str = "<span style="display:none;" mce_style="display:none;&qu ...
- qwt 6.1.0集成进Qt creator 2.8.1步骤
环境准备与文件编译 ·关于Qt 发现一个Qt正确安装的教程,非常棒!http://www.wikihow.com/Install-Qt-SDK-on-Ubuntu-Linux Qt版本是4.8.5,在 ...
- ionicPopup弹出列表选择对话框
//显示vm.selectWarehouse = function() { vm.popupForWarehouse = $ionicPopup.show({ template: '<div c ...
- js实现网页图片延时加载的原理和代码 提高网站打开速度
有时我们看到一些大型网站,页面如果有很多图片的时候,当你滚动到相应的行时,当前行的图片才即时加载的,这样子的话页面在打开只加可视区域的图片,而其它隐藏的图片则不加载,一定程序上加快了页面加载的速度,对 ...