65 #ifndef UNIV_HOTBACKUP
91 #include "xtrabackup_api.h"
96 #include <drizzled/gettext.h>
97 #include <drizzled/errmsg_print.h>
104 #ifdef HAVE_DARWIN_THREADS
105 # include <sys/utsname.h>
107 UNIV_INTERN ibool srv_have_fullfsync = FALSE;
121 static ibool srv_start_has_been_called = FALSE;
131 static ulint n[SRV_MAX_N_IO_THREADS + 7];
140 static char* srv_monitor_file_name;
144 #define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD
145 #define SRV_MAX_N_PENDING_SYNC_IOS 100
147 #ifdef UNIV_PFS_THREAD
149 UNIV_INTERN mysql_pfs_key_t io_handler_thread_key;
150 UNIV_INTERN mysql_pfs_key_t srv_lock_timeout_thread_key;
151 UNIV_INTERN mysql_pfs_key_t srv_error_monitor_thread_key;
152 UNIV_INTERN mysql_pfs_key_t srv_monitor_thread_key;
153 UNIV_INTERN mysql_pfs_key_t srv_master_thread_key;
170 size = strtoul(str, &endp, 10);
205 srv_auto_extend_last_data_file = FALSE;
206 srv_last_file_size_max = 0;
207 srv_data_file_names = NULL;
208 srv_data_file_sizes = NULL;
209 srv_data_file_is_raw_partition = NULL;
217 while (*str !=
'\0') {
220 while ((*str !=
':' && *str !=
'\0')
222 && (*(str + 1) ==
'\\' || *(str + 1) ==
'/'
223 || *(str + 1) ==
':'))) {
233 str = srv_parse_megabytes(str, &size);
235 if (0 == strncmp(str,
":autoextend",
236 (
sizeof ":autoextend") - 1)) {
238 str += (
sizeof ":autoextend") - 1;
240 if (0 == strncmp(str,
":max:",
241 (
sizeof ":max:") - 1)) {
243 str += (
sizeof ":max:") - 1;
245 str = srv_parse_megabytes(str, &size);
257 && *(str + 2) ==
'w') {
261 if (*str ==
'r' && *(str + 1) ==
'a' && *(str + 2) ==
'w') {
273 }
else if (*str !=
'\0') {
286 srv_data_file_names =
static_cast<char **
>(malloc(i *
sizeof *srv_data_file_names));
287 srv_data_file_sizes =
static_cast<ulint *
>(malloc(i *
sizeof *srv_data_file_sizes));
288 srv_data_file_is_raw_partition =
static_cast<ulint *
>(malloc(
289 i *
sizeof *srv_data_file_is_raw_partition));
291 srv_n_data_files = i;
298 while (*str !=
'\0') {
306 while ((*str !=
':' && *str !=
'\0')
308 && (*(str + 1) ==
'\\' || *(str + 1) ==
'/'
309 || *(str + 1) ==
':'))) {
319 str = srv_parse_megabytes(str, &size);
321 srv_data_file_names[i] = path;
322 srv_data_file_sizes[i] = size;
324 if (0 == strncmp(str,
":autoextend",
325 (
sizeof ":autoextend") - 1)) {
327 srv_auto_extend_last_data_file = TRUE;
329 str += (
sizeof ":autoextend") - 1;
331 if (0 == strncmp(str,
":max:",
332 (
sizeof ":max:") - 1)) {
334 str += (
sizeof ":max:") - 1;
336 str = srv_parse_megabytes(
337 str, &srv_last_file_size_max);
346 (srv_data_file_is_raw_partition)[i] = 0;
351 && *(str + 2) ==
'w') {
356 if (*str ==
'r' && *(str + 1) ==
'a' && *(str + 2) ==
'w') {
359 if ((srv_data_file_is_raw_partition)[i] == 0) {
388 srv_log_group_home_dirs = NULL;
395 while (*str !=
'\0') {
398 while (*str !=
';' && *str !=
'\0') {
406 }
else if (*str !=
'\0') {
419 srv_log_group_home_dirs =
static_cast<char **
>(malloc(i *
sizeof *srv_log_group_home_dirs));
426 while (*str !=
'\0') {
429 while (*str !=
';' && *str !=
'\0') {
438 srv_log_group_home_dirs[i] = path;
454 free(srv_data_file_names);
455 srv_data_file_names = NULL;
456 free(srv_data_file_sizes);
457 srv_data_file_sizes = NULL;
458 free(srv_data_file_is_raw_partition);
459 srv_data_file_is_raw_partition = NULL;
460 free(srv_log_group_home_dirs);
461 srv_log_group_home_dirs = NULL;
464 #ifndef UNIV_HOTBACKUP
470 io_handler_thread(
void* arg);
481 segment = *((ulint*)arg);
483 #ifdef UNIV_DEBUG_THREAD_CREATION
484 fprintf(stderr,
"Io handler thread %lu starts, id %lu\n", segment,
488 #ifdef UNIV_PFS_THREAD
489 pfs_register_thread(io_handler_thread_key);
493 fil_aio_wait(segment);
505 #define SRV_PATH_SEPARATOR '\\'
507 #define SRV_PATH_SEPARATOR '/'
520 for (; *str; str++) {
529 #ifndef UNIV_HOTBACKUP
540 return(0xFFFFFFFFUL & (file_size << UNIV_PAGE_SIZE_SHIFT));
553 return(file_size >> (32 - UNIV_PAGE_SIZE_SHIFT));
560 open_or_create_log_file(
564 ibool* log_file_created,
566 ibool log_file_has_been_opened,
580 *log_file_created = FALSE;
584 dirnamelen = strlen(srv_log_group_home_dirs[k]);
585 ut_a(dirnamelen < (
sizeof name) - 10 -
sizeof "ib_logfile");
586 memcpy(name, srv_log_group_home_dirs[k], dirnamelen);
589 if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
590 name[dirnamelen++] = SRV_PATH_SEPARATOR;
593 sprintf(name + dirnamelen,
"%s%lu",
"ib_logfile", (ulong) i);
595 files[i] = os_file_create(innodb_file_log_key, name,
596 OS_FILE_CREATE, OS_FILE_NORMAL,
607 drizzled::errmsg_printf(drizzled::error::ERROR,
608 "InnoDB: Error in creating or opening %s", name);
613 files[i] = os_file_create(innodb_file_log_key, name,
617 drizzled::errmsg_printf(drizzled::error::ERROR,
618 "InnoDB: Error in opening %s.", name);
626 if (size != srv_calc_low32(srv_log_file_size)
627 || size_high != srv_calc_high32(srv_log_file_size)) {
629 drizzled::errmsg_printf(drizzled::error::ERROR,
630 "InnoDB: Error: log file %s is of different size %lu %lu bytes than specified in the .cnf"
631 " file %lu %lu bytes!",
632 name, (ulong) size_high, (ulong) size,
633 (ulong) srv_calc_high32(srv_log_file_size),
634 (ulong) srv_calc_low32(srv_log_file_size));
639 *log_file_created = TRUE;
641 drizzled::errmsg_printf(drizzled::error::INFO,
642 "InnoDB: Log file %s did not exist: new to be created",
644 if (log_file_has_been_opened) {
649 drizzled::errmsg_printf(drizzled::error::INFO,
650 "InnoDB: Setting log file %s size to %lu MB",
651 name, (ulong) srv_log_file_size
652 >> (20 - UNIV_PAGE_SIZE_SHIFT));
654 drizzled::errmsg_printf(drizzled::error::INFO,
655 "InnoDB: Database physically writes the file full: wait...\n");
658 srv_calc_low32(srv_log_file_size),
659 srv_calc_high32(srv_log_file_size));
661 drizzled::errmsg_printf(drizzled::error::ERROR,
662 "InnoDB: Error in creating %s: probably out of disk space",
669 ret = os_file_close(files[i]);
676 fil_space_create(name,
680 ut_a(fil_validate());
682 fil_node_create(name, srv_log_file_size,
684 #ifdef UNIV_LOG_ARCHIVE
689 if (k == 0 && i == 0) {
692 fil_space_create(
"arch_log_space", arch_space_id, 0,
FIL_LOG);
694 arch_space_id = ULINT_UNDEFINED;
699 srv_log_file_size * UNIV_PAGE_SIZE,
712 open_or_create_data_files(
714 ibool* create_new_db,
716 #ifdef UNIV_LOG_ARCHIVE
717 ulint* min_arch_log_no,
719 ulint* max_arch_log_no,
722 ib_uint64_t* min_flushed_lsn,
724 ib_uint64_t* max_flushed_lsn,
726 ulint* sum_of_new_sizes)
731 ibool one_opened = FALSE;
732 ibool one_created = FALSE;
735 ulint rounded_size_pages;
738 if (srv_n_data_files >= 1000) {
739 drizzled::errmsg_printf(drizzled::error::ERROR,
740 "InnoDB: can only have < 1000 data files you have defined %lu",
741 (ulong) srv_n_data_files);
745 *sum_of_new_sizes = 0;
747 *create_new_db = FALSE;
751 for (i = 0; i < srv_n_data_files; i++) {
755 dirnamelen = strlen(srv_data_home);
757 ut_a(dirnamelen + strlen(srv_data_file_names[i])
758 < (
sizeof name) - 1);
759 memcpy(name, srv_data_home, dirnamelen);
761 if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
762 name[dirnamelen++] = SRV_PATH_SEPARATOR;
765 strcpy(name + dirnamelen, srv_data_file_names[i]);
767 if (srv_data_file_is_raw_partition[i] == 0) {
772 files[i] = os_file_create(innodb_file_data_key,
773 name, OS_FILE_CREATE,
778 != OS_FILE_ALREADY_EXISTS
786 drizzled::errmsg_printf(drizzled::error::ERROR,
787 "InnoDB: Error in creating or opening %s",
792 }
else if (srv_data_file_is_raw_partition[i] ==
SRV_NEW_RAW) {
797 srv_created_new_raw = TRUE;
799 files[i] = os_file_create(innodb_file_data_key,
800 name, OS_FILE_OPEN_RAW,
804 drizzled::errmsg_printf(drizzled::error::ERROR,
805 "InnoDB: Error in opening %s", name);
809 }
else if (srv_data_file_is_raw_partition[i] ==
SRV_OLD_RAW) {
821 drizzled::errmsg_printf(drizzled::error::ERROR,
822 "InnoDB: Error: data files can only be added at the end of a tablespace, but"
823 " data file %s existed beforehand.",
828 if (srv_data_file_is_raw_partition[i] ==
SRV_OLD_RAW) {
829 files[i] = os_file_create(
830 innodb_file_data_key,
831 name, OS_FILE_OPEN_RAW,
834 files[i] = os_file_create(
835 innodb_file_data_key,
836 name, OS_FILE_OPEN_RETRY,
839 files[i] = os_file_create(
840 innodb_file_data_key,
846 drizzled::errmsg_printf(drizzled::error::ERROR,
847 "InnoDB: Error in opening %s", name);
853 if (srv_data_file_is_raw_partition[i] ==
SRV_OLD_RAW) {
855 goto skip_size_check;
863 = (size / (1024 * 1024) + 4096 * size_high)
864 << (20 - UNIV_PAGE_SIZE_SHIFT);
866 if (i == srv_n_data_files - 1
867 && srv_auto_extend_last_data_file) {
869 if (srv_data_file_sizes[i] > rounded_size_pages
870 || (srv_last_file_size_max > 0
871 && srv_last_file_size_max
872 < rounded_size_pages)) {
874 drizzled::errmsg_printf(drizzled::error::ERROR,
875 "InnoDB: Error: auto-extending data file %s is of a different size. "
876 "%lu pages (rounded down to MB) than specified in the .cnf file: "
877 "initial %lu pages, max %lu (relevant if non-zero) pages!",
879 (ulong) rounded_size_pages,
880 (ulong) srv_data_file_sizes[i],
882 srv_last_file_size_max);
887 srv_data_file_sizes[i] = rounded_size_pages;
890 if (rounded_size_pages != srv_data_file_sizes[i]) {
892 drizzled::errmsg_printf(drizzled::error::ERROR,
893 "InnoDB: Error: data file %s is of a different size. "
894 "%lu pages (rounded down to MB). "
895 "Than specified in the .cnf file %lu pages!",
897 (ulong) rounded_size_pages,
898 (ulong) srv_data_file_sizes[i]);
903 fil_read_flushed_lsn_and_arch_log_no(
904 files[i], one_opened,
905 #ifdef UNIV_LOG_ARCHIVE
906 min_arch_log_no, max_arch_log_no,
908 min_flushed_lsn, max_flushed_lsn);
917 drizzled::errmsg_printf(drizzled::error::INFO,
918 " InnoDB: Data file %s did not exist: new to be created",
921 drizzled::errmsg_printf(drizzled::error::INFO,
922 "InnoDB: The first specified data file %s did not exist. A new database to be created!", name);
923 *create_new_db = TRUE;
926 drizzled::errmsg_printf(drizzled::error::INFO,
927 " InnoDB: Setting file %s size to %lu MB",
928 name, (ulong) (srv_data_file_sizes[i]
929 >> (20 - UNIV_PAGE_SIZE_SHIFT)));
931 drizzled::errmsg_printf(drizzled::error::INFO,
932 "InnoDB: Database physically writes the file full: wait...");
936 srv_calc_low32(srv_data_file_sizes[i]),
937 srv_calc_high32(srv_data_file_sizes[i]));
940 drizzled::errmsg_printf(drizzled::error::ERROR,
941 "InnoDB: Error in creating %s: probably out of disk space", name);
946 *sum_of_new_sizes = *sum_of_new_sizes
947 + srv_data_file_sizes[i];
950 ret = os_file_close(files[i]);
957 ut_a(fil_validate());
959 fil_node_create(name, srv_data_file_sizes[i], 0,
960 srv_data_file_is_raw_partition[i] != 0);
976 ibool log_file_created;
977 ibool log_created = FALSE;
978 ibool log_opened = FALSE;
979 ib_uint64_t min_flushed_lsn;
980 ib_uint64_t max_flushed_lsn;
981 #ifdef UNIV_LOG_ARCHIVE
982 ulint min_arch_log_no;
983 ulint max_arch_log_no;
985 ulint sum_of_new_sizes;
986 ulint sum_of_data_file_sizes;
987 ulint tablespace_size_in_header;
991 my_bool srv_file_per_table_original_value
994 #ifdef HAVE_DARWIN_THREADS
998 srv_have_fullfsync = TRUE;
1003 struct utsname utsname;
1004 if (uname(&utsname)) {
1005 fputs(_(
"InnoDB: cannot determine Mac OS X version!\n"), stderr);
1007 srv_have_fullfsync = strcmp(utsname.release,
"7.") >= 0;
1009 if (!srv_have_fullfsync) {
1010 fputs(_(
"InnoDB: On Mac OS X, fsync() may be"
1011 " broken on internal drives,\n"
1012 "InnoDB: making transactions unsafe!\n"), stderr);
1017 if (
sizeof(ulint) !=
sizeof(
void*)) {
1018 drizzled::errmsg_printf(drizzled::error::WARN,
1019 _(
"InnoDB: Error: size of InnoDB's ulint is %lu, but size of void* is %lu. "
1020 "The sizes should be the same so that on a 64-bit platform you can. Allocate more than 4 GB of memory."),
1021 (ulong)
sizeof(ulint), (ulong)
sizeof(
void*));
1030 drizzled::errmsg_printf(drizzled::error::INFO,
1031 _(
"InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n"));
1034 #ifdef UNIV_IBUF_DEBUG
1035 drizzled::errmsg_printf(drizzled::error::INFO,
1036 _(
"InnoDB: !!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!\n"
1037 # ifdef UNIV_IBUF_COUNT_DEBUG
1038 "InnoDB: !!!!!!!! UNIV_IBUF_COUNT_DEBUG switched on !!!!!!!!!\n"
1039 "InnoDB: Crash recovery will fail with UNIV_IBUF_COUNT_DEBUG\n"
1044 #ifdef UNIV_SYNC_DEBUG
1045 drizzled::errmsg_printf(drizzled::error::INFO,
1046 _(
"InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n"));
1049 #ifdef UNIV_SEARCH_DEBUG
1050 drizzled::errmsg_printf(drizzled::error::INFO,
1051 _(
"InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n"));
1054 #ifdef UNIV_LOG_LSN_DEBUG
1055 drizzled::errmsg_printf(drizzled::error::INFO,
1056 _(
"InnoDB: !!!!!!!! UNIV_LOG_LSN_DEBUG switched on !!!!!!!!!\n"));
1058 #ifdef UNIV_MEM_DEBUG
1059 drizzled::errmsg_printf(drizzled::error::INFO,
1060 _(
"InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n"));
1063 if (UNIV_LIKELY(srv_use_sys_malloc))
1065 drizzled::errmsg_printf(drizzled::error::INFO, _(
"InnoDB: The InnoDB memory heap is disabled\n"));
1069 "\nInnoDB: Compressed tables use zlib " ZLIB_VERSION
1070 #ifdef UNIV_ZIP_DEBUG
1073 #ifdef UNIV_ZIP_COPY
1074 " and extra copying"
1084 if (srv_start_has_been_called) {
1085 drizzled::errmsg_printf(drizzled::error::ERROR,
1086 "InnoDB: Error: startup called second time during the process lifetime.\n");
1089 srv_start_has_been_called = TRUE;
1109 srv_use_native_aio = FALSE;
1115 srv_use_native_aio = TRUE;
1120 srv_use_native_aio = TRUE;
1121 srv_use_native_conditions = TRUE;
1125 #elif defined(LINUX_NATIVE_AIO)
1127 if (srv_use_native_aio) {
1128 drizzled::errmsg_printf(drizzled::error::INFO,
1129 _(
"InnoDB: Using Linux native AIO"));
1135 srv_use_native_aio = FALSE;
1139 if (srv_file_flush_method_str == NULL) {
1146 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"fsync")) {
1149 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"O_DSYNC")) {
1152 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"O_DIRECT")) {
1155 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"ALL_O_DIRECT")) {
1158 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"littlesync")) {
1161 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"nosync")) {
1164 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"normal")) {
1166 srv_use_native_aio = FALSE;
1168 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
"unbuffered")) {
1170 srv_use_native_aio = FALSE;
1172 }
else if (0 ==
ut_strcmp(srv_file_flush_method_str,
1173 "async_unbuffered")) {
1177 drizzled::errmsg_printf(drizzled::error::ERROR,
1178 "InnoDB: Unrecognized value %s for innodb_flush_method",
1179 srv_file_flush_method_str);
1195 srv_max_n_threads = 50000;
1200 srv_max_n_threads = 10000;
1203 srv_max_n_threads = 1000;
1210 if (err != DB_SUCCESS) {
1215 mutex_create(srv_monitor_file_mutex_key,
1216 &srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
1218 if (srv_innodb_status) {
1219 srv_monitor_file_name =
static_cast<char *
>(mem_alloc(
1220 strlen(fil_path_to_mysql_datadir)
1221 + 20 +
sizeof "/innodb_status."));
1222 sprintf(srv_monitor_file_name,
"%s/innodb_status.%lu",
1224 srv_monitor_file = fopen(srv_monitor_file_name,
"w+");
1225 if (!srv_monitor_file) {
1226 drizzled::errmsg_printf(drizzled::error::ERROR,
1227 "InnoDB: unable to create %s: %s\n", srv_monitor_file_name, strerror(errno));
1231 srv_monitor_file_name = NULL;
1233 if (!srv_monitor_file) {
1238 mutex_create(srv_dict_tmpfile_mutex_key,
1239 &srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1242 if (!srv_dict_tmpfile) {
1246 mutex_create(srv_misc_tmpfile_mutex_key,
1247 &srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1250 if (!srv_misc_tmpfile) {
1259 srv_n_file_io_threads = 2 + srv_n_read_io_threads
1260 + srv_n_write_io_threads;
1262 ut_a(srv_n_file_io_threads <= SRV_MAX_N_IO_THREADS);
1266 if (!srv_use_native_aio) {
1267 io_limit = 8 * SRV_N_PENDING_IOS_PER_THREAD;
1269 io_limit = SRV_N_PENDING_IOS_PER_THREAD;
1272 os_aio_init(io_limit,
1273 srv_n_read_io_threads,
1274 srv_n_write_io_threads,
1275 SRV_MAX_N_PENDING_SYNC_IOS);
1278 srv_max_n_open_files);
1283 drizzled::errmsg_printf(drizzled::error::INFO,
"InnoDB: Initializing buffer pool, size = %.1fG",
1286 drizzled::errmsg_printf(drizzled::error::INFO,
"InnoDB: Initializing buffer pool, size = %.1fM",
1292 drizzled::errmsg_printf(drizzled::error::INFO,
"InnoDB: Completed initialization of buffer pool");
1294 if (err != DB_SUCCESS) {
1295 drizzled::errmsg_printf(drizzled::error::ERROR,
"InnoDB: Fatal error: cannot allocate the memory for the buffer pool");
1306 drizzled::errmsg_printf(drizzled::error::WARN,
"InnoDB: Warning: Small buffer pool size "
1307 "(%luM), the flst_validate() debug function "
1308 "can cause a deadlock if the buffer pool fills up.\n",
1320 for (i = 0; i < srv_n_file_io_threads; i++) {
1326 #ifdef UNIV_LOG_ARCHIVE
1327 if (0 !=
ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) {
1328 drizzled::errmsg_printf(drizzled::error::ERROR,
1329 "InnoDB: Error: you must set the log group home dir in my.cnf the same as log arch dir.");
1335 if (
sizeof(ulint) == 4
1336 && srv_n_log_files * srv_log_file_size
1337 >= (1UL << (32 - UNIV_PAGE_SIZE_SHIFT))) {
1338 drizzled::errmsg_printf(drizzled::error::ERROR,
1339 "InnoDB: Error: combined size of log files must be < 4 GB on 32-bit systems\n");
1344 sum_of_new_sizes = 0;
1346 for (i = 0; i < srv_n_data_files; i++) {
1348 if (
sizeof(off_t) < 5 && srv_data_file_sizes[i] >= (1UL << (32 - UNIV_PAGE_SIZE_SHIFT))) {
1349 drizzled::errmsg_printf(drizzled::error::ERROR,
1350 "InnoDB: Error: file size must be < 4 GB with this MySQL binary and operating system combination,"
1351 " in some OS's < 2 GB\n");
1356 sum_of_new_sizes += srv_data_file_sizes[i];
1359 if (sum_of_new_sizes < 10485760 / UNIV_PAGE_SIZE) {
1360 drizzled::errmsg_printf(drizzled::error::ERROR,
"InnoDB: Error: tablespace size must be at least 10 MB");
1365 err = open_or_create_data_files(&create_new_db,
1366 #ifdef UNIV_LOG_ARCHIVE
1367 &min_arch_log_no, &max_arch_log_no,
1369 &min_flushed_lsn, &max_flushed_lsn,
1371 if (err != DB_SUCCESS) {
1372 drizzled::errmsg_printf(drizzled::error::ERROR,
1373 "InnoDB: Could not open or create data files.\n"
1374 "InnoDB: If you tried to add new data files, and it failed here,\n"
1375 "InnoDB: you should now edit innodb_data_file_path in my.cnf back\n"
1376 "InnoDB: to what it was, and remove the new ibdata files InnoDB created\n"
1377 "InnoDB: in this failed attempt. InnoDB only wrote those files full of\n"
1378 "InnoDB: zeros, but did not yet use them in any way. But be careful: do not\n"
1379 "InnoDB: remove old data files which contain your precious data!\n");
1384 #ifdef UNIV_LOG_ARCHIVE
1389 for (i = 0; i < srv_n_log_files; i++) {
1390 err = open_or_create_log_file(create_new_db, &log_file_created,
1392 if (err != DB_SUCCESS) {
1397 if (log_file_created) {
1402 if ((log_opened && create_new_db)
1403 || (log_opened && log_created)) {
1404 drizzled::errmsg_printf(drizzled::error::ERROR,
1405 "InnoDB: Error: all log files must be created at the same time.\n"
1406 "InnoDB: All log files must be created also in database creation.\n"
1407 "InnoDB: If you want bigger or smaller log files, shut down the\n"
1408 "InnoDB: database and make sure there were no errors in shutdown.\n"
1409 "InnoDB: Then delete the existing log files. Edit the .cnf file\n"
1410 "InnoDB: and start the database again.\n");
1419 fil_open_log_and_system_tablespace_files();
1421 if (log_created && !create_new_db
1422 #ifdef UNIV_LOG_ARCHIVE
1423 && !srv_archive_recovery
1426 if (max_flushed_lsn != min_flushed_lsn
1427 #ifdef UNIV_LOG_ARCHIVE
1428 || max_arch_log_no != min_arch_log_no
1431 drizzled::errmsg_printf(drizzled::error::ERROR,
1432 "InnoDB: Cannot initialize created log files because\n"
1433 "InnoDB: data files were not in sync with each other\n"
1434 "InnoDB: or the data files are corrupt.\n");
1439 if (max_flushed_lsn < (ib_uint64_t) 1000) {
1440 drizzled::errmsg_printf(drizzled::error::ERROR,
1441 "InnoDB: Cannot initialize created log files because\n"
1442 "InnoDB: data files are corrupt, or new data files were\n"
1443 "InnoDB: created when the database was started previous\n"
1444 "InnoDB: time but the database was not shut down\n"
1445 "InnoDB: normally after that.\n");
1450 mutex_enter(&(log_sys->
mutex));
1452 #ifdef UNIV_LOG_ARCHIVE
1460 mutex_exit(&(log_sys->
mutex));
1465 if (create_new_db) {
1468 fsp_header_init(0, sum_of_new_sizes, &mtr);
1482 #ifdef UNIV_LOG_ARCHIVE
1483 }
else if (srv_archive_recovery) {
1484 drizzled::errmsg_printf(drizzled::error::INFO,
1485 "InnoDB: Starting archive recovery from a backup...");
1486 err = recv_recovery_from_archive_start(
1487 min_flushed_lsn, srv_archive_recovery_limit_lsn,
1489 if (err != DB_SUCCESS) {
1504 fsp_header_get_free_limit();
1506 recv_recovery_from_archive_finish();
1525 if (err != DB_SUCCESS) {
1534 buf_pool_invalidate();
1543 if (err != DB_SUCCESS) {
1559 fsp_header_get_free_limit();
1566 if (srv_apply_log_only)
1567 goto skip_processes;
1586 dict_check_tablespaces_and_store_max_id(
1601 if (!create_new_db && sum_of_new_sizes > 0) {
1605 fsp_header_inc_size(0, sum_of_new_sizes, &mtr);
1616 #ifdef UNIV_LOG_ARCHIVE
1618 if (!srv_log_archive_on) {
1621 mutex_enter(&(log_sys->
mutex));
1623 start_archive = FALSE;
1625 if (log_sys->archiving_state == LOG_ARCH_OFF) {
1626 start_archive = TRUE;
1629 mutex_exit(&(log_sys->
mutex));
1631 if (start_archive) {
1663 thread_ids + 2 + SRV_MAX_N_IO_THREADS);
1667 thread_ids + 3 + SRV_MAX_N_IO_THREADS);
1671 thread_ids + 4 + SRV_MAX_N_IO_THREADS);
1675 thread_ids + 5 + SRV_MAX_N_IO_THREADS);
1679 err = dict_create_or_check_foreign_constraint_tables();
1681 if (err != DB_SUCCESS) {
1682 return((
int)DB_ERROR);
1689 + (1 + SRV_MAX_N_IO_THREADS));
1692 ut_a(srv_n_purge_threads == 0 || srv_n_purge_threads == 1);
1696 if (srv_n_purge_threads == 1) {
1703 sum_of_data_file_sizes = 0;
1705 for (i = 0; i < srv_n_data_files; i++) {
1706 sum_of_data_file_sizes += srv_data_file_sizes[i];
1709 tablespace_size_in_header = fsp_header_get_tablespace_size();
1711 if (!srv_auto_extend_last_data_file
1712 && sum_of_data_file_sizes != tablespace_size_in_header) {
1714 drizzled::errmsg_printf(drizzled::error::ERROR,
1715 "InnoDB: Error: tablespace size stored in header is %lu pages, but the sum of data file sizes is %lu pages.",
1716 (ulong) tablespace_size_in_header,
1717 (ulong) sum_of_data_file_sizes);
1719 if (srv_force_recovery == 0
1720 && sum_of_data_file_sizes < tablespace_size_in_header) {
1724 drizzled::errmsg_printf(drizzled::error::ERROR,
1725 "InnoDB: Cannot start InnoDB. The tail of the system tablespace is "
1726 "missing. Have you edited innodb_data_file_path in my.cnf in an "
1727 "inappropriate way, removing ibdata files from there? "
1728 "You can set innodb_force_recovery=1 in my.cnf to force "
1729 "a startup if you are trying to recover a badly corrupt database.");
1735 if (srv_auto_extend_last_data_file
1736 && sum_of_data_file_sizes < tablespace_size_in_header) {
1738 drizzled::errmsg_printf(drizzled::error::ERROR,
1739 "InnoDB: Error: tablespace size stored in header is %lu pages, but the sum of data file sizes"
1740 " is only %lu pages\n",
1741 (ulong) tablespace_size_in_header,
1742 (ulong) sum_of_data_file_sizes);
1744 if (srv_force_recovery == 0) {
1746 drizzled::errmsg_printf(drizzled::error::ERROR,
1747 "InnoDB: Cannot start InnoDB. The tail of the system tablespace is "
1748 "missing. Have you edited innodb_data_file_path in my.cnf in an "
1749 "inappropriate way, removing ibdata files from there? "
1750 "You can set innodb_force_recovery=1 in my.cnf to force "
1751 "a startup if you are trying to recover a badly corrupt database.\n");
1761 drizzled::errmsg_printf(drizzled::error::ERROR,
1762 "InnoDB: Error: pthread_mutex_trylock returns an unexpected value on success! Cannot continue.\n");
1774 if (srv_print_verbose_log) {
1775 drizzled::errmsg_printf(drizzled::error::INFO,
1776 "InnoDB %s started; log sequence number %"PRIu64
"\n",
1780 if (srv_force_recovery > 0) {
1781 drizzled::errmsg_printf(drizzled::error::ERROR,
1782 "InnoDB: !!! innodb_force_recovery is set to %lu !!!\n",
1783 (ulong) srv_force_recovery);
1800 drizzled::errmsg_printf(drizzled::error::INFO,
1801 "InnoDB: You are upgrading to an InnoDB version which allows multiple. "
1802 "tablespaces. Wait that purge and insert buffer merge run to completion...");
1806 if (0 == strcmp(srv_main_thread_op_info,
1807 "waiting for server activity")) {
1814 drizzled::errmsg_printf(drizzled::error::INFO,
1815 "InnoDB: Full purge and insert buffer merge completed.");
1819 drizzled::errmsg_printf(drizzled::error::INFO,
1820 "InnoDB: You have now successfully upgraded"
1821 " to the multiple tablespaces\n"
1822 "InnoDB: format. You should NOT DOWNGRADE"
1823 " to an earlier version of\n"
1824 "InnoDB: InnoDB! But if you absolutely need to"
1826 "InnoDB: " REFMAN
"multiple-tablespaces.html\n"
1827 "InnoDB: for instructions.\n");
1830 if (srv_force_recovery == 0) {
1836 ibuf_update_max_tablespace_id();
1844 return((
int) DB_SUCCESS);
1858 drizzled::errmsg_printf(drizzled::error::ERROR,
1859 "InnoDB: Warning: shutting down a not properly started or created database!");
1871 if (srv_fast_shutdown == 2) {
1872 drizzled::errmsg_printf(drizzled::error::INFO,
1873 "InnoDB: MySQL has requested a very fast shutdown without flushing "
1874 "the InnoDB buffer pool to data files. At the next mysqld startup "
1875 "InnoDB will do a crash recovery!");
1880 if (srv_conc_n_threads != 0) {
1881 drizzled::errmsg_printf(drizzled::error::WARN,
1882 "InnoDB: Warning: query counter shows %ld queries still InnoDB: inside InnoDB at shutdown.",
1883 srv_conc_n_threads);
1894 if (srv_fast_shutdown == 2) {
1902 for (i = 0; i < 1000; i++) {
1946 drizzled::errmsg_printf(drizzled::error::WARN,
1947 "InnoDB: Warning: %lu threads created by InnoDB had not exited at shutdown!",
1951 if (srv_monitor_file) {
1952 fclose(srv_monitor_file);
1953 srv_monitor_file = 0;
1954 if (srv_monitor_file_name) {
1955 unlink(srv_monitor_file_name);
1959 if (srv_dict_tmpfile) {
1960 fclose(srv_dict_tmpfile);
1961 srv_dict_tmpfile = 0;
1964 if (srv_misc_tmpfile) {
1965 fclose(srv_misc_tmpfile);
1966 srv_misc_tmpfile = 0;
1971 btr_search_disable();
1980 mutex_free(&srv_monitor_file_mutex);
1981 mutex_free(&srv_dict_tmpfile_mutex);
1982 mutex_free(&srv_misc_tmpfile_mutex);
1984 btr_search_sys_free();
2010 || os_event_count != 0
2011 || os_mutex_count != 0
2012 || os_fast_mutex_count != 0) {
2013 drizzled::errmsg_printf(drizzled::error::WARN,
2014 "InnoDB: Warning: some resources were not cleaned up in shutdown:\n"
2015 "InnoDB: threads %lu, events %lu, os_mutexes %lu, os_fast_mutexes %lu\n",
2017 (ulong) os_mutex_count, (ulong) os_fast_mutex_count);
2020 if (dict_foreign_err_file) {
2021 fclose(dict_foreign_err_file);
2023 if (lock_latest_err_file) {
2024 fclose(lock_latest_err_file);
2027 if (srv_print_verbose_log) {
2028 drizzled::errmsg_printf(drizzled::error::INFO,
2029 "InnoDB: Shutdown completed log sequence number %"PRIu64,
2034 srv_start_has_been_called = FALSE;
2036 return((
int) DB_SUCCESS);