65 #ifndef UNIV_HOTBACKUP
90 #include "xtrabackup_api.h"
95 #include <drizzled/gettext.h>
96 #include <drizzled/errmsg_print.h>
103 #ifdef HAVE_DARWIN_THREADS
104 # include <sys/utsname.h>
106 UNIV_INTERN ibool srv_have_fullfsync = FALSE;
120 static ibool srv_start_has_been_called = FALSE;
130 static ulint n[SRV_MAX_N_IO_THREADS + 7];
139 static char* srv_monitor_file_name;
143 #define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD
144 #define SRV_MAX_N_PENDING_SYNC_IOS 100
146 #ifdef UNIV_PFS_THREAD
148 UNIV_INTERN mysql_pfs_key_t io_handler_thread_key;
149 UNIV_INTERN mysql_pfs_key_t srv_lock_timeout_thread_key;
150 UNIV_INTERN mysql_pfs_key_t srv_error_monitor_thread_key;
151 UNIV_INTERN mysql_pfs_key_t srv_monitor_thread_key;
152 UNIV_INTERN mysql_pfs_key_t srv_master_thread_key;
169 size = strtoul(str, &endp, 10);
204 srv_auto_extend_last_data_file = FALSE;
205 srv_last_file_size_max = 0;
206 srv_data_file_names = NULL;
207 srv_data_file_sizes = NULL;
208 srv_data_file_is_raw_partition = NULL;
216 while (*str !=
'\0') {
219 while ((*str !=
':' && *str !=
'\0')
221 && (*(str + 1) ==
'\\' || *(str + 1) ==
'/'
222 || *(str + 1) ==
':'))) {
232 str = srv_parse_megabytes(str, &size);
234 if (0 == strncmp(str,
":autoextend",
235 (
sizeof ":autoextend") - 1)) {
237 str += (
sizeof ":autoextend") - 1;
239 if (0 == strncmp(str,
":max:",
240 (
sizeof ":max:") - 1)) {
242 str += (
sizeof ":max:") - 1;
244 str = srv_parse_megabytes(str, &size);
256 && *(str + 2) ==
'w') {
260 if (*str ==
'r' && *(str + 1) ==
'a' && *(str + 2) ==
'w') {
272 }
else if (*str !=
'\0') {
285 srv_data_file_names =
static_cast<char **
>(malloc(i *
sizeof *srv_data_file_names));
286 srv_data_file_sizes =
static_cast<ulint *
>(malloc(i *
sizeof *srv_data_file_sizes));
287 srv_data_file_is_raw_partition =
static_cast<ulint *
>(malloc(
288 i *
sizeof *srv_data_file_is_raw_partition));
290 srv_n_data_files = i;
297 while (*str !=
'\0') {
305 while ((*str !=
':' && *str !=
'\0')
307 && (*(str + 1) ==
'\\' || *(str + 1) ==
'/'
308 || *(str + 1) ==
':'))) {
318 str = srv_parse_megabytes(str, &size);
320 srv_data_file_names[i] = path;
321 srv_data_file_sizes[i] = size;
323 if (0 == strncmp(str,
":autoextend",
324 (
sizeof ":autoextend") - 1)) {
326 srv_auto_extend_last_data_file = TRUE;
328 str += (
sizeof ":autoextend") - 1;
330 if (0 == strncmp(str,
":max:",
331 (
sizeof ":max:") - 1)) {
333 str += (
sizeof ":max:") - 1;
335 str = srv_parse_megabytes(
336 str, &srv_last_file_size_max);
345 (srv_data_file_is_raw_partition)[i] = 0;
350 && *(str + 2) ==
'w') {
355 if (*str ==
'r' && *(str + 1) ==
'a' && *(str + 2) ==
'w') {
358 if ((srv_data_file_is_raw_partition)[i] == 0) {
387 srv_log_group_home_dirs = NULL;
394 while (*str !=
'\0') {
397 while (*str !=
';' && *str !=
'\0') {
405 }
else if (*str !=
'\0') {
418 srv_log_group_home_dirs =
static_cast<char **
>(malloc(i *
sizeof *srv_log_group_home_dirs));
425 while (*str !=
'\0') {
428 while (*str !=
';' && *str !=
'\0') {
437 srv_log_group_home_dirs[i] = path;
453 free(srv_data_file_names);
454 srv_data_file_names = NULL;
455 free(srv_data_file_sizes);
456 srv_data_file_sizes = NULL;
457 free(srv_data_file_is_raw_partition);
458 srv_data_file_is_raw_partition = NULL;
459 free(srv_log_group_home_dirs);
460 srv_log_group_home_dirs = NULL;
463 #ifndef UNIV_HOTBACKUP
469 io_handler_thread(
void* arg);
480 segment = *((ulint*)arg);
482 #ifdef UNIV_DEBUG_THREAD_CREATION
483 fprintf(stderr,
"Io handler thread %lu starts, id %lu\n", segment,
487 #ifdef UNIV_PFS_THREAD
488 pfs_register_thread(io_handler_thread_key);
504 #define SRV_PATH_SEPARATOR '\\'
506 #define SRV_PATH_SEPARATOR '/'
519 for (; *str; str++) {
528 #ifndef UNIV_HOTBACKUP
539 return(0xFFFFFFFFUL & (file_size << UNIV_PAGE_SIZE_SHIFT));
552 return(file_size >> (32 - UNIV_PAGE_SIZE_SHIFT));
559 open_or_create_log_file(
563 ibool* log_file_created,
565 ibool log_file_has_been_opened,
579 *log_file_created = FALSE;
583 dirnamelen = strlen(srv_log_group_home_dirs[k]);
584 ut_a(dirnamelen < (
sizeof name) - 10 -
sizeof "ib_logfile");
585 memcpy(name, srv_log_group_home_dirs[k], dirnamelen);
588 if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
589 name[dirnamelen++] = SRV_PATH_SEPARATOR;
592 sprintf(name + dirnamelen,
"%s%lu",
"ib_logfile", (ulong) i);
594 files[i] = os_file_create(innodb_file_log_key, name,
595 OS_FILE_CREATE, OS_FILE_NORMAL,
606 drizzled::errmsg_printf(drizzled::error::ERROR,
607 "InnoDB: Error in creating or opening %s", name);
612 files[i] = os_file_create(innodb_file_log_key, name,
616 drizzled::errmsg_printf(drizzled::error::ERROR,
617 "InnoDB: Error in opening %s.", name);
625 if (size != srv_calc_low32(srv_log_file_size)
626 || size_high != srv_calc_high32(srv_log_file_size)) {
628 drizzled::errmsg_printf(drizzled::error::ERROR,
629 "InnoDB: Error: log file %s is of different size %lu %lu bytes than specified in the .cnf"
630 " file %lu %lu bytes!",
631 name, (ulong) size_high, (ulong) size,
632 (ulong) srv_calc_high32(srv_log_file_size),
633 (ulong) srv_calc_low32(srv_log_file_size));
638 *log_file_created = TRUE;
640 drizzled::errmsg_printf(drizzled::error::INFO,
641 "InnoDB: Log file %s did not exist: new to be created",
643 if (log_file_has_been_opened) {
648 drizzled::errmsg_printf(drizzled::error::INFO,
649 "InnoDB: Setting log file %s size to %lu MB",
650 name, (ulong) srv_log_file_size
651 >> (20 - UNIV_PAGE_SIZE_SHIFT));
653 drizzled::errmsg_printf(drizzled::error::INFO,
654 "InnoDB: Database physically writes the file full: wait...\n");
657 srv_calc_low32(srv_log_file_size),
658 srv_calc_high32(srv_log_file_size));
660 drizzled::errmsg_printf(drizzled::error::ERROR,
661 "InnoDB: Error in creating %s: probably out of disk space",
668 ret = os_file_close(files[i]);
683 #ifdef UNIV_LOG_ARCHIVE
688 if (k == 0 && i == 0) {
693 arch_space_id = ULINT_UNDEFINED;
698 srv_log_file_size * UNIV_PAGE_SIZE,
711 open_or_create_data_files(
713 ibool* create_new_db,
715 #ifdef UNIV_LOG_ARCHIVE
716 ulint* min_arch_log_no,
718 ulint* max_arch_log_no,
721 ib_uint64_t* min_flushed_lsn,
723 ib_uint64_t* max_flushed_lsn,
725 ulint* sum_of_new_sizes)
730 ibool one_opened = FALSE;
731 ibool one_created = FALSE;
734 ulint rounded_size_pages;
737 if (srv_n_data_files >= 1000) {
738 drizzled::errmsg_printf(drizzled::error::ERROR,
739 "InnoDB: can only have < 1000 data files you have defined %lu",
740 (ulong) srv_n_data_files);
744 *sum_of_new_sizes = 0;
746 *create_new_db = FALSE;
750 for (i = 0; i < srv_n_data_files; i++) {
754 dirnamelen = strlen(srv_data_home);
756 ut_a(dirnamelen + strlen(srv_data_file_names[i])
757 < (
sizeof name) - 1);
758 memcpy(name, srv_data_home, dirnamelen);
760 if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
761 name[dirnamelen++] = SRV_PATH_SEPARATOR;
764 strcpy(name + dirnamelen, srv_data_file_names[i]);
766 if (srv_data_file_is_raw_partition[i] == 0) {
771 files[i] = os_file_create(innodb_file_data_key,
772 name, OS_FILE_CREATE,
777 != OS_FILE_ALREADY_EXISTS
785 drizzled::errmsg_printf(drizzled::error::ERROR,
786 "InnoDB: Error in creating or opening %s",
791 }
else if (srv_data_file_is_raw_partition[i] ==
SRV_NEW_RAW) {
796 srv_created_new_raw = TRUE;
798 files[i] = os_file_create(innodb_file_data_key,
799 name, OS_FILE_OPEN_RAW,
803 drizzled::errmsg_printf(drizzled::error::ERROR,
804 "InnoDB: Error in opening %s", name);
808 }
else if (srv_data_file_is_raw_partition[i] ==
SRV_OLD_RAW) {
820 drizzled::errmsg_printf(drizzled::error::ERROR,
821 "InnoDB: Error: data files can only be added at the end of a tablespace, but"
822 " data file %s existed beforehand.",
827 if (srv_data_file_is_raw_partition[i] ==
SRV_OLD_RAW) {
828 files[i] = os_file_create(
829 innodb_file_data_key,
830 name, OS_FILE_OPEN_RAW,
833 files[i] = os_file_create(
834 innodb_file_data_key,
835 name, OS_FILE_OPEN_RETRY,
838 files[i] = os_file_create(
839 innodb_file_data_key,
845 drizzled::errmsg_printf(drizzled::error::ERROR,
846 "InnoDB: Error in opening %s", name);
852 if (srv_data_file_is_raw_partition[i] ==
SRV_OLD_RAW) {
854 goto skip_size_check;
862 = (size / (1024 * 1024) + 4096 * size_high)
863 << (20 - UNIV_PAGE_SIZE_SHIFT);
865 if (i == srv_n_data_files - 1
866 && srv_auto_extend_last_data_file) {
868 if (srv_data_file_sizes[i] > rounded_size_pages
869 || (srv_last_file_size_max > 0
870 && srv_last_file_size_max
871 < rounded_size_pages)) {
873 drizzled::errmsg_printf(drizzled::error::ERROR,
874 "InnoDB: Error: auto-extending data file %s is of a different size. "
875 "%lu pages (rounded down to MB) than specified in the .cnf file: "
876 "initial %lu pages, max %lu (relevant if non-zero) pages!",
878 (ulong) rounded_size_pages,
879 (ulong) srv_data_file_sizes[i],
881 srv_last_file_size_max);
886 srv_data_file_sizes[i] = rounded_size_pages;
889 if (rounded_size_pages != srv_data_file_sizes[i]) {
891 drizzled::errmsg_printf(drizzled::error::ERROR,
892 "InnoDB: Error: data file %s is of a different size. "
893 "%lu pages (rounded down to MB). "
894 "Than specified in the .cnf file %lu pages!",
896 (ulong) rounded_size_pages,
897 (ulong) srv_data_file_sizes[i]);
903 files[i], one_opened,
904 #ifdef UNIV_LOG_ARCHIVE
905 min_arch_log_no, max_arch_log_no,
907 min_flushed_lsn, max_flushed_lsn);
916 drizzled::errmsg_printf(drizzled::error::INFO,
917 " InnoDB: Data file %s did not exist: new to be created",
920 drizzled::errmsg_printf(drizzled::error::INFO,
921 "InnoDB: The first specified data file %s did not exist. A new database to be created!", name);
922 *create_new_db = TRUE;
925 drizzled::errmsg_printf(drizzled::error::INFO,
926 " InnoDB: Setting file %s size to %lu MB",
927 name, (ulong) (srv_data_file_sizes[i]
928 >> (20 - UNIV_PAGE_SIZE_SHIFT)));
930 drizzled::errmsg_printf(drizzled::error::INFO,
931 "InnoDB: Database physically writes the file full: wait...");
935 srv_calc_low32(srv_data_file_sizes[i]),
936 srv_calc_high32(srv_data_file_sizes[i]));
939 drizzled::errmsg_printf(drizzled::error::ERROR,
940 "InnoDB: Error in creating %s: probably out of disk space", name);
945 *sum_of_new_sizes = *sum_of_new_sizes
946 + srv_data_file_sizes[i];
949 ret = os_file_close(files[i]);
959 srv_data_file_is_raw_partition[i] != 0);
975 ibool log_file_created;
976 ibool log_created = FALSE;
977 ibool log_opened = FALSE;
978 ib_uint64_t min_flushed_lsn;
979 ib_uint64_t max_flushed_lsn;
980 #ifdef UNIV_LOG_ARCHIVE
981 ulint min_arch_log_no;
982 ulint max_arch_log_no;
984 ulint sum_of_new_sizes;
985 ulint sum_of_data_file_sizes;
986 ulint tablespace_size_in_header;
990 my_bool srv_file_per_table_original_value
993 #ifdef HAVE_DARWIN_THREADS
997 srv_have_fullfsync = TRUE;
1002 struct utsname utsname;
1003 if (uname(&utsname)) {
1004 fputs(_(
"InnoDB: cannot determine Mac OS X version!\n"), stderr);
1006 srv_have_fullfsync = strcmp(utsname.release,
"7.") >= 0;
1008 if (!srv_have_fullfsync) {
1009 fputs(_(
"InnoDB: On Mac OS X, fsync() may be"
1010 " broken on internal drives,\n"
1011 "InnoDB: making transactions unsafe!\n"), stderr);
1016 if (
sizeof(ulint) !=
sizeof(
void*)) {
1017 drizzled::errmsg_printf(drizzled::error::WARN,
1018 _(
"InnoDB: Error: size of InnoDB's ulint is %lu, but size of void* is %lu. "
1019 "The sizes should be the same so that on a 64-bit platform you can. Allocate more than 4 GB of memory."),
1020 (ulong)
sizeof(ulint), (ulong)
sizeof(
void*));
1029 drizzled::errmsg_printf(drizzled::error::INFO,
1030 _(
"InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n"));
1033 #ifdef UNIV_IBUF_DEBUG
1034 drizzled::errmsg_printf(drizzled::error::INFO,
1035 _(
"InnoDB: !!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!\n"
1036 # ifdef UNIV_IBUF_COUNT_DEBUG
1037 "InnoDB: !!!!!!!! UNIV_IBUF_COUNT_DEBUG switched on !!!!!!!!!\n"
1038 "InnoDB: Crash recovery will fail with UNIV_IBUF_COUNT_DEBUG\n"
1043 #ifdef UNIV_BLOB_DEBUG
1045 "InnoDB: !!!!!!!! UNIV_BLOB_DEBUG switched on !!!!!!!!!\n"
1046 "InnoDB: Server restart may fail with UNIV_BLOB_DEBUG\n");
1049 #ifdef UNIV_SYNC_DEBUG
1050 drizzled::errmsg_printf(drizzled::error::INFO,
1051 _(
"InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n"));
1054 #ifdef UNIV_SEARCH_DEBUG
1055 drizzled::errmsg_printf(drizzled::error::INFO,
1056 _(
"InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n"));
1059 #ifdef UNIV_LOG_LSN_DEBUG
1060 drizzled::errmsg_printf(drizzled::error::INFO,
1061 _(
"InnoDB: !!!!!!!! UNIV_LOG_LSN_DEBUG switched on !!!!!!!!!\n"));
1063 #ifdef UNIV_MEM_DEBUG
1064 drizzled::errmsg_printf(drizzled::error::INFO,
1065 _(
"InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n"));
1068 if (UNIV_LIKELY(srv_use_sys_malloc))
1070 drizzled::errmsg_printf(drizzled::error::INFO, _(
"InnoDB: The InnoDB memory heap is disabled\n"));
1074 "\nInnoDB: Compressed tables use zlib " ZLIB_VERSION
1075 #ifdef UNIV_ZIP_DEBUG
1078 #ifdef UNIV_ZIP_COPY
1079 " and extra copying"
1089 if (srv_start_has_been_called) {
1090 drizzled::errmsg_printf(drizzled::error::ERROR,
1091 "InnoDB: Error: startup called second time during the process lifetime.\n");
1094 srv_start_has_been_called = TRUE;
1105 switch (os_get_os_version()) {
1114 srv_use_native_aio = FALSE;
1120 srv_use_native_aio = TRUE;
1125 srv_use_native_aio = TRUE;
1126 srv_use_native_conditions = TRUE;
1130 #elif defined(LINUX_NATIVE_AIO)
1132 if (srv_use_native_aio) {
1133 drizzled::errmsg_printf(drizzled::error::INFO,
1134 _(
"InnoDB: Using Linux native AIO"));
1140 srv_use_native_aio = FALSE;
1144 if (srv_file_flush_method_str == NULL) {
1151 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"fsync")) {
1154 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"O_DSYNC")) {
1157 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"O_DIRECT")) {
1160 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"ALL_O_DIRECT")) {
1163 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"littlesync")) {
1166 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"nosync")) {
1169 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"normal")) {
1171 srv_use_native_aio = FALSE;
1173 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"unbuffered")) {
1175 srv_use_native_aio = FALSE;
1177 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
1178 "async_unbuffered")) {
1182 drizzled::errmsg_printf(drizzled::error::ERROR,
1183 "InnoDB: Unrecognized value %s for innodb_flush_method",
1184 srv_file_flush_method_str);
1200 srv_max_n_threads = 50000;
1205 srv_max_n_threads = 10000;
1208 srv_max_n_threads = 1000;
1215 if (err != DB_SUCCESS) {
1220 mutex_create(srv_monitor_file_mutex_key,
1221 &srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
1223 if (srv_innodb_status) {
1224 srv_monitor_file_name =
static_cast<char *
>(mem_alloc(
1226 + 20 +
sizeof "/innodb_status."));
1227 sprintf(srv_monitor_file_name,
"%s/innodb_status.%lu",
1229 srv_monitor_file = fopen(srv_monitor_file_name,
"w+");
1230 if (!srv_monitor_file) {
1231 drizzled::errmsg_printf(drizzled::error::ERROR,
1232 "InnoDB: unable to create %s: %s\n", srv_monitor_file_name, strerror(errno));
1236 srv_monitor_file_name = NULL;
1238 if (!srv_monitor_file) {
1243 mutex_create(srv_dict_tmpfile_mutex_key,
1244 &srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1247 if (!srv_dict_tmpfile) {
1251 mutex_create(srv_misc_tmpfile_mutex_key,
1252 &srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1255 if (!srv_misc_tmpfile) {
1264 srv_n_file_io_threads = 2 + srv_n_read_io_threads
1265 + srv_n_write_io_threads;
1267 ut_a(srv_n_file_io_threads <= SRV_MAX_N_IO_THREADS);
1269 io_limit = 8 * SRV_N_PENDING_IOS_PER_THREAD;
1275 if (srv_use_native_aio) {
1276 io_limit = SRV_N_PENDING_IOS_PER_THREAD;
1280 os_aio_init(io_limit,
1281 srv_n_read_io_threads,
1282 srv_n_write_io_threads,
1283 SRV_MAX_N_PENDING_SYNC_IOS);
1286 srv_max_n_open_files);
1291 drizzled::errmsg_printf(drizzled::error::INFO,
"InnoDB: Initializing buffer pool, size = %.1fG",
1294 drizzled::errmsg_printf(drizzled::error::INFO,
"InnoDB: Initializing buffer pool, size = %.1fM",
1300 drizzled::errmsg_printf(drizzled::error::INFO,
"InnoDB: Completed initialization of buffer pool");
1302 if (err != DB_SUCCESS) {
1303 drizzled::errmsg_printf(drizzled::error::ERROR,
"InnoDB: Fatal error: cannot allocate memory for the buffer pool");
1314 drizzled::errmsg_printf(drizzled::error::WARN,
"InnoDB: Warning: Small buffer pool size "
1315 "(%luM), the flst_validate() debug function "
1316 "can cause a deadlock if the buffer pool fills up.\n",
1328 for (i = 0; i < srv_n_file_io_threads; i++) {
1334 #ifdef UNIV_LOG_ARCHIVE
1335 if (0 !=
ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) {
1336 drizzled::errmsg_printf(drizzled::error::ERROR,
1337 "InnoDB: Error: you must set the log group home dir in my.cnf the same as log arch dir.");
1343 if (
sizeof(ulint) == 4
1344 && srv_n_log_files * srv_log_file_size
1345 >= (1UL << (32 - UNIV_PAGE_SIZE_SHIFT))) {
1346 drizzled::errmsg_printf(drizzled::error::ERROR,
1347 "InnoDB: Error: combined size of log files must be < 4 GB on 32-bit systems\n");
1352 sum_of_new_sizes = 0;
1354 for (i = 0; i < srv_n_data_files; i++) {
1356 if (
sizeof(off_t) < 5 && srv_data_file_sizes[i] >= (1UL << (32 - UNIV_PAGE_SIZE_SHIFT))) {
1357 drizzled::errmsg_printf(drizzled::error::ERROR,
1358 "InnoDB: Error: file size must be < 4 GB with this MySQL binary and operating system combination,"
1359 " in some OS's < 2 GB\n");
1364 sum_of_new_sizes += srv_data_file_sizes[i];
1367 if (sum_of_new_sizes < 10485760 / UNIV_PAGE_SIZE) {
1368 drizzled::errmsg_printf(drizzled::error::ERROR,
"InnoDB: Error: tablespace size must be at least 10 MB");
1373 err = open_or_create_data_files(&create_new_db,
1374 #ifdef UNIV_LOG_ARCHIVE
1375 &min_arch_log_no, &max_arch_log_no,
1377 &min_flushed_lsn, &max_flushed_lsn,
1379 if (err != DB_SUCCESS) {
1380 drizzled::errmsg_printf(drizzled::error::ERROR,
1381 "InnoDB: Could not open or create data files.\n"
1382 "InnoDB: If you tried to add new data files, and it failed here,\n"
1383 "InnoDB: you should now edit innodb_data_file_path in my.cnf back\n"
1384 "InnoDB: to what it was, and remove the new ibdata files InnoDB created\n"
1385 "InnoDB: in this failed attempt. InnoDB only wrote those files full of\n"
1386 "InnoDB: zeros, but did not yet use them in any way. But be careful: do not\n"
1387 "InnoDB: remove old data files which contain your precious data!\n");
1392 #ifdef UNIV_LOG_ARCHIVE
1397 for (i = 0; i < srv_n_log_files; i++) {
1398 err = open_or_create_log_file(create_new_db, &log_file_created,
1400 if (err != DB_SUCCESS) {
1405 if (log_file_created) {
1410 if ((log_opened && create_new_db)
1411 || (log_opened && log_created)) {
1412 drizzled::errmsg_printf(drizzled::error::ERROR,
1413 "InnoDB: Error: all log files must be created at the same time.\n"
1414 "InnoDB: All log files must be created also in database creation.\n"
1415 "InnoDB: If you want bigger or smaller log files, shut down the\n"
1416 "InnoDB: database and make sure there were no errors in shutdown.\n"
1417 "InnoDB: Then delete the existing log files. Edit the .cnf file\n"
1418 "InnoDB: and start the database again.\n");
1429 if (log_created && !create_new_db
1430 #ifdef UNIV_LOG_ARCHIVE
1431 && !srv_archive_recovery
1434 if (max_flushed_lsn != min_flushed_lsn
1435 #ifdef UNIV_LOG_ARCHIVE
1436 || max_arch_log_no != min_arch_log_no
1439 drizzled::errmsg_printf(drizzled::error::ERROR,
1440 "InnoDB: Cannot initialize created log files because\n"
1441 "InnoDB: data files were not in sync with each other\n"
1442 "InnoDB: or the data files are corrupt.\n");
1447 if (max_flushed_lsn < (ib_uint64_t) 1000) {
1448 drizzled::errmsg_printf(drizzled::error::ERROR,
1449 "InnoDB: Cannot initialize created log files because\n"
1450 "InnoDB: data files are corrupt, or new data files were\n"
1451 "InnoDB: created when the database was started previous\n"
1452 "InnoDB: time but the database was not shut down\n"
1453 "InnoDB: normally after that.\n");
1458 mutex_enter(&(log_sys->
mutex));
1460 #ifdef UNIV_LOG_ARCHIVE
1468 mutex_exit(&(log_sys->
mutex));
1473 if (create_new_db) {
1490 #ifdef UNIV_LOG_ARCHIVE
1491 }
else if (srv_archive_recovery) {
1492 drizzled::errmsg_printf(drizzled::error::INFO,
1493 "InnoDB: Starting archive recovery from a backup...");
1494 err = recv_recovery_from_archive_start(
1495 min_flushed_lsn, srv_archive_recovery_limit_lsn,
1497 if (err != DB_SUCCESS) {
1514 recv_recovery_from_archive_finish();
1533 if (err != DB_SUCCESS) {
1551 if (err != DB_SUCCESS) {
1574 if (srv_apply_log_only)
1575 goto skip_processes;
1609 if (!create_new_db && sum_of_new_sizes > 0) {
1624 #ifdef UNIV_LOG_ARCHIVE
1626 if (!srv_log_archive_on) {
1629 mutex_enter(&(log_sys->
mutex));
1631 start_archive = FALSE;
1633 if (log_sys->archiving_state == LOG_ARCH_OFF) {
1634 start_archive = TRUE;
1637 mutex_exit(&(log_sys->
mutex));
1639 if (start_archive) {
1671 thread_ids + 2 + SRV_MAX_N_IO_THREADS);
1675 thread_ids + 3 + SRV_MAX_N_IO_THREADS);
1679 thread_ids + 4 + SRV_MAX_N_IO_THREADS);
1683 thread_ids + 5 + SRV_MAX_N_IO_THREADS);
1689 if (err != DB_SUCCESS) {
1690 return((
int)DB_ERROR);
1697 + (1 + SRV_MAX_N_IO_THREADS));
1700 ut_a(srv_n_purge_threads == 0 || srv_n_purge_threads == 1);
1704 if (srv_n_purge_threads == 1) {
1712 || (srv_n_purge_threads == 1
1714 == ULINT_UNDEFINED)) {
1717 fprintf(stderr,
" InnoDB: "
1718 "Waiting for the background threads to "
1729 sum_of_data_file_sizes = 0;
1731 for (i = 0; i < srv_n_data_files; i++) {
1732 sum_of_data_file_sizes += srv_data_file_sizes[i];
1737 if (!srv_auto_extend_last_data_file
1738 && sum_of_data_file_sizes != tablespace_size_in_header) {
1740 drizzled::errmsg_printf(drizzled::error::ERROR,
1741 "InnoDB: Error: tablespace size stored in header is %lu pages, but the sum of data file sizes is %lu pages.",
1742 (ulong) tablespace_size_in_header,
1743 (ulong) sum_of_data_file_sizes);
1745 if (srv_force_recovery == 0
1746 && sum_of_data_file_sizes < tablespace_size_in_header) {
1750 drizzled::errmsg_printf(drizzled::error::ERROR,
1751 "InnoDB: Cannot start InnoDB. The tail of the system tablespace is "
1752 "missing. Have you edited innodb_data_file_path in my.cnf in an "
1753 "inappropriate way, removing ibdata files from there? "
1754 "You can set innodb_force_recovery=1 in my.cnf to force "
1755 "a startup if you are trying to recover a badly corrupt database.");
1761 if (srv_auto_extend_last_data_file
1762 && sum_of_data_file_sizes < tablespace_size_in_header) {
1764 drizzled::errmsg_printf(drizzled::error::ERROR,
1765 "InnoDB: Error: tablespace size stored in header is %lu pages, but the sum of data file sizes"
1766 " is only %lu pages\n",
1767 (ulong) tablespace_size_in_header,
1768 (ulong) sum_of_data_file_sizes);
1770 if (srv_force_recovery == 0) {
1772 drizzled::errmsg_printf(drizzled::error::ERROR,
1773 "InnoDB: Cannot start InnoDB. The tail of the system tablespace is "
1774 "missing. Have you edited innodb_data_file_path in my.cnf in an "
1775 "inappropriate way, removing ibdata files from there? "
1776 "You can set innodb_force_recovery=1 in my.cnf to force "
1777 "a startup if you are trying to recover a badly corrupt database.\n");
1787 drizzled::errmsg_printf(drizzled::error::ERROR,
1788 "InnoDB: Error: pthread_mutex_trylock returns an unexpected value on success! Cannot continue.\n");
1800 if (srv_print_verbose_log) {
1801 drizzled::errmsg_printf(drizzled::error::INFO,
1802 "InnoDB %s started; log sequence number %"PRIu64
"\n",
1806 if (srv_force_recovery > 0) {
1807 drizzled::errmsg_printf(drizzled::error::ERROR,
1808 "InnoDB: !!! innodb_force_recovery is set to %lu !!!\n",
1809 (ulong) srv_force_recovery);
1826 drizzled::errmsg_printf(drizzled::error::INFO,
1827 "InnoDB: You are upgrading to an InnoDB version which allows multiple. "
1828 "tablespaces. Wait that purge and insert buffer merge run to completion...");
1832 if (0 == strcmp(srv_main_thread_op_info,
1833 "waiting for server activity")) {
1840 drizzled::errmsg_printf(drizzled::error::INFO,
1841 "InnoDB: Full purge and insert buffer merge completed.");
1845 drizzled::errmsg_printf(drizzled::error::INFO,
1846 "InnoDB: You have now successfully upgraded"
1847 " to the multiple tablespaces\n"
1848 "InnoDB: format. You should NOT DOWNGRADE"
1849 " to an earlier version of\n"
1850 "InnoDB: InnoDB! But if you absolutely need to"
1852 "InnoDB: " REFMAN
"multiple-tablespaces.html\n"
1853 "InnoDB: for instructions.\n");
1856 if (srv_force_recovery == 0) {
1870 return((
int) DB_SUCCESS);
1884 drizzled::errmsg_printf(drizzled::error::ERROR,
1885 "InnoDB: Warning: shutting down a not properly started or created database!");
1897 if (srv_fast_shutdown == 2) {
1898 drizzled::errmsg_printf(drizzled::error::INFO,
1899 "InnoDB: MySQL has requested a very fast shutdown without flushing "
1900 "the InnoDB buffer pool to data files. At the next mysqld startup "
1901 "InnoDB will do a crash recovery!");
1906 if (srv_conc_n_threads != 0) {
1907 drizzled::errmsg_printf(drizzled::error::WARN,
1908 "InnoDB: Warning: query counter shows %ld queries still InnoDB: inside InnoDB at shutdown.",
1909 srv_conc_n_threads);
1920 if (srv_fast_shutdown == 2) {
1928 for (i = 0; i < 1000; i++) {
1972 drizzled::errmsg_printf(drizzled::error::WARN,
1973 "InnoDB: Warning: %lu threads created by InnoDB had not exited at shutdown!",
1977 if (srv_monitor_file) {
1978 fclose(srv_monitor_file);
1979 srv_monitor_file = 0;
1980 if (srv_monitor_file_name) {
1981 unlink(srv_monitor_file_name);
1985 if (srv_dict_tmpfile) {
1986 fclose(srv_dict_tmpfile);
1987 srv_dict_tmpfile = 0;
1990 if (srv_misc_tmpfile) {
1991 fclose(srv_misc_tmpfile);
1992 srv_misc_tmpfile = 0;
2005 mutex_free(&srv_monitor_file_mutex);
2006 mutex_free(&srv_dict_tmpfile_mutex);
2007 mutex_free(&srv_misc_tmpfile_mutex);
2035 || os_event_count != 0
2036 || os_mutex_count != 0
2037 || os_fast_mutex_count != 0) {
2038 drizzled::errmsg_printf(drizzled::error::WARN,
2039 "InnoDB: Warning: some resources were not cleaned up in shutdown:\n"
2040 "InnoDB: threads %lu, events %lu, os_mutexes %lu, os_fast_mutexes %lu\n",
2042 (ulong) os_mutex_count, (ulong) os_fast_mutex_count);
2045 if (dict_foreign_err_file) {
2046 fclose(dict_foreign_err_file);
2048 if (lock_latest_err_file) {
2049 fclose(lock_latest_err_file);
2052 if (srv_print_verbose_log) {
2053 drizzled::errmsg_printf(drizzled::error::INFO,
2054 "InnoDB: Shutdown completed log sequence number %"PRIu64,
2059 srv_start_has_been_called = FALSE;
2061 return((
int) DB_SUCCESS);
UNIV_INTERN void srv_free(void)
trx_doublewrite_t * trx_doublewrite
UNIV_INTERN void srv_wake_purge_thread(void)
UNIV_INTERN void trx_sys_create_rsegs(ulint n_rsegs)
UNIV_INTERN ulint dict_create_or_check_foreign_constraint_tables(void)
UNIV_INTERN void recv_reset_logs(ib_uint64_t lsn, ibool new_logs_created)
FILE * os_file_create_tmpfile(void)
#define IB_ATOMICS_STARTUP_MSG
UNIV_INTERN void trx_sys_file_format_tag_init(void)
UNIV_INTERN void os_fast_mutex_unlock(os_fast_mutex_t *fast_mutex)
UNIV_INTERN void trx_sys_file_format_init(void)
UNIV_INTERN os_thread_ret_t srv_error_monitor_thread(void *arg)
UNIV_INTERN void fsp_init(void)
UNIV_INTERN ibool srv_parse_log_group_home_dirs(char *str)
UNIV_INTERN void trx_sys_file_format_close(void)
UNIV_INTERN int innobase_start_or_create_for_mysql(void)
UNIV_INTERN void sync_close(void)
pthread_mutex_t os_fast_mutex_t
UNIV_INTERN void logs_empty_and_mark_files_at_shutdown(void)
UNIV_INTERN void srv_wake_master_thread(void)
UNIV_INTERN ibool os_file_get_size(os_file_t file, ulint *size, ulint *size_high)
UNIV_INTERN os_thread_t os_thread_create(os_posix_f_t start_f, void *arg, os_thread_id_t *thread_id)
UNIV_INTERN void os_fast_mutex_free(os_fast_mutex_t *fast_mutex)
UNIV_INTERN void log_init(void)
UNIV_INTERN ulint fsp_header_get_free_limit(void)
const char * fil_path_to_mysql_datadir
UNIV_INTERN void mem_close(void)
UNIV_INTERN int innobase_shutdown_for_mysql(void)
UNIV_INTERN void lock_sys_close(void)
UNIV_INTERN void os_fast_mutex_init(os_fast_mutex_t *fast_mutex)
UNIV_INTERN void ut_free_all_mem(void)
UNIV_INTERN void srv_free_paths_and_sizes(void)
ibool trx_doublewrite_must_reset_space_ids
UNIV_INTERN void fil_node_create(const char *name, ulint size, ulint id, ibool is_raw)
UNIV_INTERN void trx_sys_init_at_db_start(void)
UNIV_INTERN void dict_create(void)
UNIV_INTERN void recv_recovery_rollback_active(void)
UNIV_INTERN void os_aio_wake_all_threads_at_shutdown(void)
UNIV_INTERN void os_mutex_enter(os_mutex_t mutex)
UNIV_INTERN ulint log_archive_archivelog(void)
UNIV_INTERN void trx_sys_mark_upgraded_to_multiple_tablespaces(void)
UNIV_INTERN ulint fsp_header_get_tablespace_size(void)
UNIV_INTERN void btr_search_disable(void)
UNIV_INTERN ulint log_archive_noarchivelog(void)
UNIV_INTERN os_thread_ret_t srv_monitor_thread(void *arg)
UNIV_INTERN void fsp_header_inc_size(ulint space, ulint size_inc, mtr_t *mtr)
UNIV_INTERN void dict_check_tablespaces_and_store_max_id(ibool in_crash_recovery)
UNIV_INTERN void dict_close(void)
#define recv_recovery_from_checkpoint_start(type, lim, min, max)
UNIV_INTERN void mtr_commit(mtr_t *mtr) __attribute__((nonnull))
UNIV_INTERN ulint buf_pool_init(ulint size, ulint n_instances)
UNIV_INTERN ulint srv_boot(void)
UNIV_INTERN void fil_init(ulint hash_size, ulint max_n_open)
UNIV_INTERN void log_buffer_flush_to_disk(void)
UNIV_INTERN void fil_close(void)
UNIV_INTERN char * srv_add_path_separator_if_needed(char *str)
ibool srv_start_raw_disk_in_use
UNIV_INTERN void log_group_init(ulint id, ulint n_files, ulint file_size, ulint space_id, ulint archive_space_id)
UNIV_INTERN ulint os_proc_get_number(void)
UNIV_INTERN void btr_search_sys_free(void)
UNIV_INTERN void os_mutex_exit(os_mutex_t mutex)
UNIV_INTERN void os_event_set(os_event_t event)
UNIV_INTERN void buf_pool_invalidate(void)
UNIV_INTERN void os_thread_sleep(ulint tm)
UNIV_INTERN void trx_sys_close(void)
UNIV_INTERN void fil_read_flushed_lsn_and_arch_log_no(os_file_t data_file, ibool one_read_already, ib_uint64_t *min_flushed_lsn, ib_uint64_t *max_flushed_lsn)
UNIV_INTERN ulint trx_sys_file_format_max_check(ulint max_format_id)
ibool recv_needed_recovery
ib_uint64_t srv_start_lsn
UNIV_INTERN ibool ibuf_is_empty(void)
UNIV_INTERN ulint os_file_get_last_error(ibool report_all_errors)
UNIV_INTERN void buf_pool_free(ulint n_instances)
UNIV_INTERN void srv_normalize_path_for_win(char *str)
UNIV_INTERN void pars_lexer_close(void)
UNIV_INTERN os_thread_ret_t srv_master_thread(void *arg)
UNIV_INTERN os_thread_ret_t srv_LRU_dump_restore_thread(void *arg)
my_bool srv_file_per_table
UNIV_INTERN os_thread_ret_t srv_purge_thread(void *)
#define SRV_LOG_SPACE_FIRST_ID
ulint srv_max_file_format_at_startup
os_thread_t os_thread_id_t
UNIV_INTERN void trx_sys_create(void)
UNIV_INTERN ibool os_file_set_size(const char *name, os_file_t file, ulint size, ulint size_high)
UNIV_INTERN ibool fil_space_create(const char *name, ulint id, ulint zip_size, ulint purpose)
UNIV_INLINE ulint os_fast_mutex_trylock(os_fast_mutex_t *fast_mutex)
UNIV_INTERN void fil_open_log_and_system_tablespace_files(void)
UNIV_INTERN void recv_recovery_from_checkpoint_finish(void)
UNIV_INTERN void trx_sys_create_doublewrite_buf(void)
UNIV_INTERN os_thread_ret_t srv_lock_timeout_thread(void *arg)
UNIV_INTERN void ut_print_timestamp(FILE *file)
UNIV_INTERN os_thread_id_t os_thread_get_curr_id(void)
UNIV_INTERN void ibuf_update_max_tablespace_id(void)
UNIV_INTERN void fil_aio_wait(ulint segment)
UNIV_INTERN void os_sync_free(void)
UNIV_INTERN ulint srv_thread_has_reserved_slot(enum srv_thread_type type)
ibool srv_is_being_started
UNIV_INLINE void mtr_start(mtr_t *mtr) __attribute__((nonnull))
UNIV_INTERN void dict_boot(void)
UNIV_INTERN void os_fast_mutex_lock(os_fast_mutex_t *fast_mutex)
UNIV_INTERN ibool srv_parse_data_file_paths_and_sizes(char *str)
UNIV_INTERN void lock_sys_create(ulint n_cells)
ib_uint64_t srv_shutdown_lsn
ibool srv_startup_is_before_trx_rollback_phase
UNIV_INTERN void ibuf_close(void)
ulint srv_buf_pool_instances
UNIV_INTERN void fsp_header_init(ulint space, ulint size, mtr_t *mtr)
UNIV_INTERN ibool fil_validate(void)
UNIV_INTERN ulint os_thread_pf(os_thread_id_t a)
UNIV_INLINE int ut_strcmp(const char *str1, const char *str2)