1
1
/*****************************************************************************
3
Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
4
Copyright (C) 2008, Google Inc.
5
Copyright (C) 2009, Percona Inc.
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
4
Copyright (c) 2008, Google Inc.
7
6
Portions of this file contain modifications contributed and copyrighted by
8
7
Google, Inc. Those modifications are gratefully acknowledged and are described
10
9
incorporated with their permission, and subject to the conditions contained in
11
10
the file COPYING.Google.
13
Portions of this file contain modifications contributed and copyrighted
14
by Percona Inc.. Those modifications are
15
gratefully acknowledged and are described briefly in the InnoDB
16
documentation. The contributions by Percona Inc. are incorporated with
17
their permission, and subject to the conditions contained in the file
20
12
This program is free software; you can redistribute it and/or modify it under
21
13
the terms of the GNU General Public License as published by the Free Software
22
14
Foundation; version 2 of the License.
26
18
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
28
20
You should have received a copy of the GNU General Public License along with
29
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
30
St, Fifth Floor, Boston, MA 02110-1301 USA
21
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22
Place, Suite 330, Boston, MA 02111-1307 USA
32
24
*****************************************************************************/
25
/***********************************************************************
27
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
28
Copyright (c) 2009, Percona Inc.
30
Portions of this file contain modifications contributed and copyrighted
31
by Percona Inc.. Those modifications are
32
gratefully acknowledged and are described briefly in the InnoDB
33
documentation. The contributions by Percona Inc. are incorporated with
34
their permission, and subject to the conditions contained in the file
37
This program is free software; you can redistribute it and/or modify it
38
under the terms of the GNU General Public License as published by the
39
Free Software Foundation; version 2 of the License.
41
This program is distributed in the hope that it will be useful, but
42
WITHOUT ANY WARRANTY; without even the implied warranty of
43
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
44
Public License for more details.
46
You should have received a copy of the GNU General Public License along
47
with this program; if not, write to the Free Software Foundation, Inc.,
48
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
50
***********************************************************************/
34
52
/********************************************************************//**
35
53
@file srv/srv0start.c
126
138
/** Files comprising the system tablespace */
127
139
static os_file_t files[1000];
141
/** Mutex protecting the ios count */
142
static mutex_t ios_mutex;
143
/** Count of I/O operations in io_handler_thread() */
129
146
/** io_handler_thread parameters for thread identification */
130
static ulint n[SRV_MAX_N_IO_THREADS + 6];
147
static ulint n[SRV_MAX_N_IO_THREADS + 5];
131
148
/** io_handler_thread identifiers */
132
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6];
149
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 5];
134
151
/** We use this mutex to test the return value of pthread_mutex_trylock
135
152
on successful locking. HP-UX does NOT return 0, though Linux et al do. */
143
160
#define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD
144
161
#define SRV_MAX_N_PENDING_SYNC_IOS 100
146
#ifdef UNIV_PFS_THREAD
147
/* Keys to register InnoDB threads with performance schema */
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;
153
#endif /* UNIV_PFS_THREAD */
155
164
/*********************************************************************//**
156
165
Convert a numeric string that optionally ends in G or M, to a number
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));
294
srv_data_file_names = malloc(i * sizeof *srv_data_file_names);
295
srv_data_file_sizes = malloc(i * sizeof *srv_data_file_sizes);
296
srv_data_file_is_raw_partition = malloc(
297
i * sizeof *srv_data_file_is_raw_partition);
290
299
srv_n_data_files = i;
483
489
fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,
484
490
os_thread_pf(os_thread_get_curr_id()));
487
#ifdef UNIV_PFS_THREAD
488
pfs_register_thread(io_handler_thread_key);
489
#endif /* UNIV_PFS_THREAD */
491
while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) {
492
493
fil_aio_wait(segment);
495
mutex_enter(&ios_mutex);
497
mutex_exit(&ios_mutex);
495
500
/* We count the number of threads in os_thread_exit(). A created
496
501
thread should always use that to exit and not use return() to exit.
497
502
The thread actually never comes here because it is exited in an
498
503
os_event_wait(). */
504
#if (!defined(__SUNPRO_C) && !defined(__SUNPRO_CC))
501
508
#endif /* !UNIV_HOTBACKUP */
535
/*********************************************************************//**
536
Adds a slash or a backslash to the end of a string if it is missing
537
and the string is not empty.
538
@return string which has the separator if the string is not empty */
541
srv_add_path_separator_if_needed(
542
/*=============================*/
543
char* str) /*!< in: null-terminated character string */
546
ulint len = ut_strlen(str);
548
if (len == 0 || str[len - 1] == SRV_PATH_SEPARATOR) {
553
out_str = ut_malloc(len + 2);
554
memcpy(out_str, str, len);
555
out_str[len] = SRV_PATH_SEPARATOR;
556
out_str[len + 1] = 0;
528
561
#ifndef UNIV_HOTBACKUP
529
562
/*********************************************************************//**
530
563
Calculates the low 32 bits when a file size which is given as a number
575
608
char name[10000];
578
610
UT_NOT_USED(create_new_db);
580
612
*log_file_created = FALSE;
582
614
srv_normalize_path_for_win(srv_log_group_home_dirs[k]);
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);
588
/* Add a path separator if needed. */
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,
615
srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed(
616
srv_log_group_home_dirs[k]);
618
ut_a(strlen(srv_log_group_home_dirs[k])
619
< (sizeof name) - 10 - sizeof "ib_logfile");
620
sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k],
621
"ib_logfile", (ulong) i);
623
files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL,
597
624
OS_LOG_FILE, &ret);
598
625
if (ret == FALSE) {
599
626
if (os_file_get_last_error(FALSE) != OS_FILE_ALREADY_EXISTS
604
631
&& os_file_get_last_error(FALSE) != 100
607
drizzled::errmsg_printf(drizzled::error::ERROR,
608
"InnoDB: Error in creating or opening %s", name);
635
"InnoDB: Error in creating"
636
" or opening %s\n", name);
613
files[i] = os_file_create(innodb_file_log_key, name,
614
OS_FILE_OPEN, OS_FILE_AIO,
641
files[i] = os_file_create(name, OS_FILE_OPEN, OS_FILE_AIO,
615
642
OS_LOG_FILE, &ret);
617
drizzled::errmsg_printf(drizzled::error::ERROR,
618
"InnoDB: Error in opening %s.", name);
645
"InnoDB: Error in opening %s\n", name);
620
647
return(DB_ERROR);
626
653
if (size != srv_calc_low32(srv_log_file_size)
627
654
|| 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));
657
"InnoDB: Error: log file %s is"
658
" of different size %lu %lu bytes\n"
659
"InnoDB: than specified in the .cnf"
660
" file %lu %lu bytes!\n",
661
name, (ulong) size_high, (ulong) size,
662
(ulong) srv_calc_high32(srv_log_file_size),
663
(ulong) srv_calc_low32(srv_log_file_size));
636
665
return(DB_ERROR);
639
668
*log_file_created = TRUE;
641
drizzled::errmsg_printf(drizzled::error::INFO,
642
"InnoDB: Log file %s did not exist: new to be created",
670
ut_print_timestamp(stderr);
673
" InnoDB: Log file %s did not exist:"
674
" new to be created\n",
644
676
if (log_file_has_been_opened) {
646
678
return(DB_ERROR);
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));
681
fprintf(stderr, "InnoDB: Setting log file %s size to %lu MB\n",
682
name, (ulong) srv_log_file_size
683
>> (20 - UNIV_PAGE_SIZE_SHIFT));
654
drizzled::errmsg_printf(drizzled::error::INFO,
655
"InnoDB: Database physically writes the file full: wait...\n");
686
"InnoDB: Database physically writes the file"
657
689
ret = os_file_set_size(name, files[i],
658
690
srv_calc_low32(srv_log_file_size),
659
691
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",
694
"InnoDB: Error in creating %s:"
695
" probably out of disk space\n",
665
698
return(DB_ERROR);
737
770
char name[10000];
739
772
if (srv_n_data_files >= 1000) {
740
drizzled::errmsg_printf(drizzled::error::ERROR,
741
"InnoDB: can only have < 1000 data files you have defined %lu",
742
(ulong) srv_n_data_files);
773
fprintf(stderr, "InnoDB: can only have < 1000 data files\n"
774
"InnoDB: you have defined %lu\n",
775
(ulong) srv_n_data_files);
743
776
return(DB_ERROR);
748
781
*create_new_db = FALSE;
750
783
srv_normalize_path_for_win(srv_data_home);
784
srv_data_home = srv_add_path_separator_if_needed(srv_data_home);
752
786
for (i = 0; i < srv_n_data_files; i++) {
755
787
srv_normalize_path_for_win(srv_data_file_names[i]);
756
dirnamelen = strlen(srv_data_home);
758
ut_a(dirnamelen + strlen(srv_data_file_names[i])
789
ut_a(strlen(srv_data_home) + strlen(srv_data_file_names[i])
759
790
< (sizeof name) - 1);
760
memcpy(name, srv_data_home, dirnamelen);
761
/* Add a path separator if needed. */
762
if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
763
name[dirnamelen++] = SRV_PATH_SEPARATOR;
766
strcpy(name + dirnamelen, srv_data_file_names[i]);
791
sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]);
768
793
if (srv_data_file_is_raw_partition[i] == 0) {
770
795
/* First we try to create the file: if it already
771
796
exists, ret will get value FALSE */
773
files[i] = os_file_create(innodb_file_data_key,
774
name, OS_FILE_CREATE,
798
files[i] = os_file_create(name, OS_FILE_CREATE,
776
800
OS_DATA_FILE, &ret);
797
822
srv_start_raw_disk_in_use = TRUE;
798
823
srv_created_new_raw = TRUE;
800
files[i] = os_file_create(innodb_file_data_key,
801
name, OS_FILE_OPEN_RAW,
825
files[i] = os_file_create(name, OS_FILE_OPEN_RAW,
803
827
OS_DATA_FILE, &ret);
805
drizzled::errmsg_printf(drizzled::error::ERROR,
806
"InnoDB: Error in opening %s", name);
830
"InnoDB: Error in opening %s\n", name);
808
832
return(DB_ERROR);
819
843
/* We open the data file */
821
845
if (one_created) {
822
drizzled::errmsg_printf(drizzled::error::ERROR,
823
"InnoDB: Error: data files can only be added at the end of a tablespace, but"
824
" data file %s existed beforehand.",
847
"InnoDB: Error: data files can only"
848
" be added at the end\n");
850
"InnoDB: of a tablespace, but"
851
" data file %s existed beforehand.\n",
826
853
return(DB_ERROR);
829
856
if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
830
857
files[i] = os_file_create(
831
innodb_file_data_key,
832
858
name, OS_FILE_OPEN_RAW,
833
859
OS_FILE_NORMAL, OS_DATA_FILE, &ret);
834
860
} else if (i == 0) {
835
861
files[i] = os_file_create(
836
innodb_file_data_key,
837
862
name, OS_FILE_OPEN_RETRY,
838
863
OS_FILE_NORMAL, OS_DATA_FILE, &ret);
840
865
files[i] = os_file_create(
841
innodb_file_data_key,
842
866
name, OS_FILE_OPEN, OS_FILE_NORMAL,
843
867
OS_DATA_FILE, &ret);
847
drizzled::errmsg_printf(drizzled::error::ERROR,
848
"InnoDB: Error in opening %s", name);
872
"InnoDB: Error in opening %s\n", name);
849
873
os_file_get_last_error(TRUE);
851
875
return(DB_ERROR);
872
896
&& srv_last_file_size_max
873
897
< rounded_size_pages)) {
875
drizzled::errmsg_printf(drizzled::error::ERROR,
876
"InnoDB: Error: auto-extending data file %s is of a different size. "
877
"%lu pages (rounded down to MB) than specified in the .cnf file: "
878
"initial %lu pages, max %lu (relevant if non-zero) pages!",
880
(ulong) rounded_size_pages,
881
(ulong) srv_data_file_sizes[i],
883
srv_last_file_size_max);
900
"InnoDB: Error: auto-extending"
902
" of a different size\n"
903
"InnoDB: %lu pages (rounded"
904
" down to MB) than specified"
905
" in the .cnf file:\n"
906
"InnoDB: initial %lu pages,"
907
" max %lu (relevant if"
908
" non-zero) pages!\n",
910
(ulong) rounded_size_pages,
911
(ulong) srv_data_file_sizes[i],
913
srv_last_file_size_max);
885
915
return(DB_ERROR);
891
921
if (rounded_size_pages != srv_data_file_sizes[i]) {
893
drizzled::errmsg_printf(drizzled::error::ERROR,
894
"InnoDB: Error: data file %s is of a different size. "
895
"%lu pages (rounded down to MB). "
896
"Than specified in the .cnf file %lu pages!",
924
"InnoDB: Error: data file %s"
925
" is of a different size\n"
927
" (rounded down to MB)\n"
928
"InnoDB: than specified"
929
" in the .cnf file %lu pages!\n",
898
931
(ulong) rounded_size_pages,
899
932
(ulong) srv_data_file_sizes[i]);
915
948
one_created = TRUE;
918
drizzled::errmsg_printf(drizzled::error::INFO,
919
" InnoDB: Data file %s did not exist: new to be created",
951
ut_print_timestamp(stderr);
953
" InnoDB: Data file %s did not"
954
" exist: new to be created\n",
922
drizzled::errmsg_printf(drizzled::error::INFO,
923
"InnoDB: The first specified data file %s did not exist. A new database to be created!", name);
958
"InnoDB: The first specified"
959
" data file %s did not exist:\n"
960
"InnoDB: a new database"
961
" to be created!\n", name);
924
962
*create_new_db = TRUE;
927
drizzled::errmsg_printf(drizzled::error::INFO,
928
" InnoDB: Setting file %s size to %lu MB",
929
name, (ulong) (srv_data_file_sizes[i]
930
>> (20 - UNIV_PAGE_SIZE_SHIFT)));
965
ut_print_timestamp(stderr);
967
" InnoDB: Setting file %s size to %lu MB\n",
969
(ulong) (srv_data_file_sizes[i]
970
>> (20 - UNIV_PAGE_SIZE_SHIFT)));
932
drizzled::errmsg_printf(drizzled::error::INFO,
933
"InnoDB: Database physically writes the file full: wait...");
973
"InnoDB: Database physically writes the"
974
" file full: wait...\n");
935
976
ret = os_file_set_size(
1003
1050
on Mac OS X 10.3 or later. */
1004
1051
struct utsname utsname;
1005
1052
if (uname(&utsname)) {
1006
fputs(_("InnoDB: cannot determine Mac OS X version!\n"), stderr);
1053
fputs("InnoDB: cannot determine Mac OS X version!\n", stderr);
1008
1055
srv_have_fullfsync = strcmp(utsname.release, "7.") >= 0;
1010
1057
if (!srv_have_fullfsync) {
1011
fputs(_("InnoDB: On Mac OS X, fsync() may be"
1012
" broken on internal drives,\n"
1013
"InnoDB: making transactions unsafe!\n"), stderr);
1058
fputs("InnoDB: On Mac OS X, fsync() may be"
1059
" broken on internal drives,\n"
1060
"InnoDB: making transactions unsafe!\n", stderr);
1015
1062
# endif /* F_FULLFSYNC */
1016
1063
#endif /* HAVE_DARWIN_THREADS */
1018
1065
if (sizeof(ulint) != sizeof(void*)) {
1019
drizzled::errmsg_printf(drizzled::error::WARN,
1020
_("InnoDB: Error: size of InnoDB's ulint is %lu, but size of void* is %lu. "
1021
"The sizes should be the same so that on a 64-bit platform you can. Allocate more than 4 GB of memory."),
1067
"InnoDB: Error: size of InnoDB's ulint is %lu,"
1068
" but size of void* is %lu.\n"
1069
"InnoDB: The sizes should be the same"
1070
" so that on a 64-bit platform you can\n"
1071
"InnoDB: allocate more than 4 GB of memory.",
1022
1072
(ulong)sizeof(ulint), (ulong)sizeof(void*));
1028
1078
innodb_file_per_table) until this function has returned. */
1029
1079
srv_file_per_table = FALSE;
1030
1080
#ifdef UNIV_DEBUG
1031
drizzled::errmsg_printf(drizzled::error::INFO,
1032
_("InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n"));
1082
"InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n");
1035
1085
#ifdef UNIV_IBUF_DEBUG
1036
drizzled::errmsg_printf(drizzled::error::INFO,
1037
_("InnoDB: !!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!\n"
1038
# ifdef UNIV_IBUF_COUNT_DEBUG
1039
"InnoDB: !!!!!!!! UNIV_IBUF_COUNT_DEBUG switched on !!!!!!!!!\n"
1040
"InnoDB: Crash recovery will fail with UNIV_IBUF_COUNT_DEBUG\n"
1087
"InnoDB: !!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!\n"
1088
"InnoDB: Crash recovery will fail with UNIV_IBUF_DEBUG\n");
1045
1091
#ifdef UNIV_SYNC_DEBUG
1046
drizzled::errmsg_printf(drizzled::error::INFO,
1047
_("InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n"));
1093
"InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n");
1050
1096
#ifdef UNIV_SEARCH_DEBUG
1051
drizzled::errmsg_printf(drizzled::error::INFO,
1052
_("InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n"));
1098
"InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n");
1055
#ifdef UNIV_LOG_LSN_DEBUG
1056
drizzled::errmsg_printf(drizzled::error::INFO,
1057
_("InnoDB: !!!!!!!! UNIV_LOG_LSN_DEBUG switched on !!!!!!!!!\n"));
1058
#endif /* UNIV_LOG_LSN_DEBUG */
1059
1101
#ifdef UNIV_MEM_DEBUG
1060
drizzled::errmsg_printf(drizzled::error::INFO,
1061
_("InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n"));
1103
"InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n");
1064
if (UNIV_LIKELY(srv_use_sys_malloc))
1066
drizzled::errmsg_printf(drizzled::error::ERROR, _("InnoDB: The InnoDB memory heap is disabled\n"));
1106
if (UNIV_LIKELY(srv_use_sys_malloc)) {
1108
"InnoDB: The InnoDB memory heap is disabled\n");
1069
fputs("InnoDB: " IB_ATOMICS_STARTUP_MSG
1070
"\nInnoDB: Compressed tables use zlib " ZLIB_VERSION
1071
#ifdef UNIV_ZIP_DEBUG
1073
#endif /* UNIV_ZIP_DEBUG */
1074
#ifdef UNIV_ZIP_COPY
1075
" and extra copying"
1076
#endif /* UNIV_ZIP_COPY */
1111
#ifdef HAVE_GCC_ATOMIC_BUILTINS
1112
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1114
"InnoDB: Mutexes and rw_locks use GCC atomic builtins.\n");
1115
# else /* INNODB_RW_LOCKS_USE_ATOMICS */
1117
"InnoDB: Mutexes use GCC atomic builtins, rw_locks do not.\n");
1118
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1119
#elif defined(HAVE_SOLARIS_ATOMICS)
1120
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1122
"InnoDB: Mutexes and rw_locks use Solaris atomic functions.\n");
1125
"InnoDB: Mutexes use Solaris atomic functions.\n");
1126
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1127
#elif defined(HAVE_WINDOWS_ATOMICS)
1128
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1130
"InnoDB: Mutexes and rw_locks use Windows interlocked functions.\n");
1133
"InnoDB: Mutexes use Windows interlocked functions.\n");
1134
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1135
#else /* HAVE_GCC_ATOMIC_BUILTINS */
1137
"InnoDB: Neither mutexes nor rw_locks use GCC atomic builtins.\n");
1138
#endif /* HAVE_GCC_ATOMIC_BUILTINS */
1080
1140
/* Since InnoDB does not currently clean up all its internal data
1081
1141
structures in MySQL Embedded Server Library server_end(), we
1083
1143
second time during the process lifetime. */
1085
1145
if (srv_start_has_been_called) {
1086
drizzled::errmsg_printf(drizzled::error::ERROR,
1087
"InnoDB: Error: startup called second time during the process lifetime.\n");
1147
"InnoDB: Error:startup called second time"
1148
" during the process lifetime.\n"
1149
"InnoDB: In the MySQL Embedded Server Library"
1150
" you cannot call server_init()\n"
1151
"InnoDB: more than once during"
1152
" the process lifetime.\n");
1090
1155
srv_start_has_been_called = TRUE;
1107
1173
but when run in conjunction with InnoDB Hot Backup, it seemed
1108
1174
to corrupt the data files. */
1110
srv_use_native_aio = FALSE;
1115
/* On 2000 and XP, async IO is available. */
1116
srv_use_native_aio = TRUE;
1176
os_aio_use_native_aio = FALSE;
1120
/* Vista and later have both async IO and condition variables */
1121
srv_use_native_aio = TRUE;
1122
srv_use_native_conditions = TRUE;
1179
/* On Win 2000 and XP use async i/o */
1180
os_aio_use_native_aio = TRUE;
1126
#elif defined(LINUX_NATIVE_AIO)
1128
if (srv_use_native_aio) {
1129
drizzled::errmsg_printf(drizzled::error::INFO,
1130
_("InnoDB: Using Linux native AIO"));
1133
/* Currently native AIO is supported only on windows and linux
1134
and that also when the support is compiled in. In all other
1135
cases, we ignore the setting of innodb_use_native_aio. */
1136
srv_use_native_aio = FALSE;
1140
1184
if (srv_file_flush_method_str == NULL) {
1141
1185
/* These are the default options */
1162
1206
} else if (0 == ut_strcmp(srv_file_flush_method_str, "normal")) {
1163
1207
srv_win_file_flush_method = SRV_WIN_IO_NORMAL;
1164
srv_use_native_aio = FALSE;
1208
os_aio_use_native_aio = FALSE;
1166
1210
} else if (0 == ut_strcmp(srv_file_flush_method_str, "unbuffered")) {
1167
1211
srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
1168
srv_use_native_aio = FALSE;
1212
os_aio_use_native_aio = FALSE;
1170
1214
} else if (0 == ut_strcmp(srv_file_flush_method_str,
1171
1215
"async_unbuffered")) {
1172
1216
srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
1175
drizzled::errmsg_printf(drizzled::error::ERROR,
1176
"InnoDB: Unrecognized value %s for innodb_flush_method",
1177
srv_file_flush_method_str);
1220
"InnoDB: Unrecognized value %s for"
1221
" innodb_flush_method\n",
1222
srv_file_flush_method_str);
1178
1223
return(DB_ERROR);
1186
1231
maximum number of threads that can wait in the 'srv_conc array' for
1187
1232
their time to enter InnoDB. */
1234
#if defined(__NETWARE__)
1236
/* Create less event semaphores because Win 98/ME had
1237
difficulty creating 40000 event semaphores. Comment from
1238
Novell, Inc.: also, these just take a lot of memory on
1240
srv_max_n_threads = 1000;
1189
1242
if (srv_buf_pool_size >= 1000 * 1024 * 1024) {
1190
1243
/* If buffer pool is less than 1000 MB,
1191
assume fewer threads. Also use only one
1192
buffer pool instance */
1244
assume fewer threads. */
1193
1245
srv_max_n_threads = 50000;
1195
1247
} else if (srv_buf_pool_size >= 8 * 1024 * 1024) {
1197
srv_buf_pool_instances = 1;
1198
1249
srv_max_n_threads = 10000;
1200
srv_buf_pool_instances = 1;
1201
1251
srv_max_n_threads = 1000; /* saves several MB of memory,
1202
1252
especially in 64-bit
1206
1256
err = srv_boot();
1208
1258
if (err != DB_SUCCESS) {
1210
1260
return((int) err);
1213
mutex_create(srv_monitor_file_mutex_key,
1214
&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
1263
mutex_create(&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
1216
1265
if (srv_innodb_status) {
1217
srv_monitor_file_name = static_cast<char *>(mem_alloc(
1266
srv_monitor_file_name = mem_alloc(
1218
1267
strlen(fil_path_to_mysql_datadir)
1219
+ 20 + sizeof "/innodb_status."));
1268
+ 20 + sizeof "/innodb_status.");
1220
1269
sprintf(srv_monitor_file_name, "%s/innodb_status.%lu",
1221
1270
fil_path_to_mysql_datadir, os_proc_get_number());
1222
1271
srv_monitor_file = fopen(srv_monitor_file_name, "w+");
1223
1272
if (!srv_monitor_file) {
1224
drizzled::errmsg_printf(drizzled::error::ERROR,
1225
"InnoDB: unable to create %s: %s\n", srv_monitor_file_name, strerror(errno));
1273
fprintf(stderr, "InnoDB: unable to create %s: %s\n",
1274
srv_monitor_file_name, strerror(errno));
1226
1275
return(DB_ERROR);
1236
mutex_create(srv_dict_tmpfile_mutex_key,
1237
&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1285
mutex_create(&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1239
1287
srv_dict_tmpfile = os_file_create_tmpfile();
1240
1288
if (!srv_dict_tmpfile) {
1241
1289
return(DB_ERROR);
1244
mutex_create(srv_misc_tmpfile_mutex_key,
1245
&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1292
mutex_create(&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1247
1294
srv_misc_tmpfile = os_file_create_tmpfile();
1248
1295
if (!srv_misc_tmpfile) {
1275
1322
fil_init(srv_file_per_table ? 50000 : 5000,
1276
1323
srv_max_n_open_files);
1278
/* Print time to initialize the buffer pool */
1280
if (srv_buf_pool_size >= 1024 * 1024 * 1024) {
1281
drizzled::errmsg_printf(drizzled::error::INFO, "InnoDB: Initializing buffer pool, size = %.1fG",
1282
((double) srv_buf_pool_size) / (1024 * 1024 * 1024));
1284
drizzled::errmsg_printf(drizzled::error::INFO, "InnoDB: Initializing buffer pool, size = %.1fM",
1285
((double) srv_buf_pool_size) / (1024 * 1024));
1288
err = buf_pool_init(srv_buf_pool_size, srv_buf_pool_instances);
1290
drizzled::errmsg_printf(drizzled::error::INFO, "InnoDB: Completed initialization of buffer pool");
1292
if (err != DB_SUCCESS) {
1293
drizzled::errmsg_printf(drizzled::error::ERROR, "InnoDB: Fatal error: cannot allocate the memory for the buffer pool");
1325
ret = buf_pool_init();
1329
"InnoDB: Fatal error: cannot allocate the memory"
1330
" for the buffer pool\n");
1298
1335
#ifdef UNIV_DEBUG
1302
1339
if (srv_buf_pool_size <= 5 * 1024 * 1024) {
1304
drizzled::errmsg_printf(drizzled::error::WARN, "InnoDB: Warning: Small buffer pool size "
1305
"(%luM), the flst_validate() debug function "
1306
"can cause a deadlock if the buffer pool fills up.\n",
1307
srv_buf_pool_size / 1024 / 1024);
1341
fprintf(stderr, "InnoDB: Warning: Small buffer pool size "
1342
"(%luM), the flst_validate() debug function "
1343
"can cause a deadlock if the buffer pool fills up.\n",
1344
srv_buf_pool_size / 1024 / 1024);
1324
1361
#ifdef UNIV_LOG_ARCHIVE
1325
1362
if (0 != ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) {
1326
drizzled::errmsg_printf(drizzled::error::ERROR,
1327
"InnoDB: Error: you must set the log group home dir in my.cnf the same as log arch dir.");
1364
"InnoDB: Error: you must set the log group"
1365
" home dir in my.cnf the\n"
1366
"InnoDB: same as log arch dir.\n");
1329
1368
return(DB_ERROR);
1331
1370
#endif /* UNIV_LOG_ARCHIVE */
1333
1372
if (srv_n_log_files * srv_log_file_size >= 262144) {
1334
drizzled::errmsg_printf(drizzled::error::ERROR,
1335
"InnoDB: Error: combined size of log files must be < 4 GB");
1374
"InnoDB: Error: combined size of log files"
1375
" must be < 4 GB\n");
1337
1377
return(DB_ERROR);
1342
1382
for (i = 0; i < srv_n_data_files; i++) {
1343
1383
#ifndef __WIN__
1344
1384
if (sizeof(off_t) < 5 && srv_data_file_sizes[i] >= 262144) {
1345
drizzled::errmsg_printf(drizzled::error::ERROR,
1346
"InnoDB: Error: file size must be < 4 GB with this MySQL binary and operating system combination,"
1347
" in some OS's < 2 GB\n");
1386
"InnoDB: Error: file size must be < 4 GB"
1387
" with this MySQL binary\n"
1388
"InnoDB: and operating system combination,"
1389
" in some OS's < 2 GB\n");
1349
1391
return(DB_ERROR);
1365
1409
&min_flushed_lsn, &max_flushed_lsn,
1366
1410
&sum_of_new_sizes);
1367
1411
if (err != DB_SUCCESS) {
1368
drizzled::errmsg_printf(drizzled::error::ERROR,
1369
"InnoDB: Could not open or create data files.\n"
1370
"InnoDB: If you tried to add new data files, and it failed here,\n"
1371
"InnoDB: you should now edit innodb_data_file_path in my.cnf back\n"
1372
"InnoDB: to what it was, and remove the new ibdata files InnoDB created\n"
1373
"InnoDB: in this failed attempt. InnoDB only wrote those files full of\n"
1374
"InnoDB: zeros, but did not yet use them in any way. But be careful: do not\n"
1375
"InnoDB: remove old data files which contain your precious data!\n");
1413
"InnoDB: Could not open or create data files.\n"
1414
"InnoDB: If you tried to add new data files,"
1415
" and it failed here,\n"
1416
"InnoDB: you should now edit innodb_data_file_path"
1418
"InnoDB: to what it was, and remove the"
1419
" new ibdata files InnoDB created\n"
1420
"InnoDB: in this failed attempt. InnoDB only wrote"
1421
" those files full of\n"
1422
"InnoDB: zeros, but did not yet use them in any way."
1423
" But be careful: do not\n"
1424
"InnoDB: remove old data files"
1425
" which contain your precious data!\n");
1377
1427
return((int) err);
1398
1448
if ((log_opened && create_new_db)
1399
1449
|| (log_opened && log_created)) {
1400
drizzled::errmsg_printf(drizzled::error::ERROR,
1401
"InnoDB: Error: all log files must be created at the same time.\n"
1402
"InnoDB: All log files must be created also in database creation.\n"
1403
"InnoDB: If you want bigger or smaller log files, shut down the\n"
1404
"InnoDB: database and make sure there were no errors in shutdown.\n"
1405
"InnoDB: Then delete the existing log files. Edit the .cnf file\n"
1451
"InnoDB: Error: all log files must be"
1452
" created at the same time.\n"
1453
"InnoDB: All log files must be"
1454
" created also in database creation.\n"
1455
"InnoDB: If you want bigger or smaller"
1456
" log files, shut down the\n"
1457
"InnoDB: database and make sure there"
1458
" were no errors in shutdown.\n"
1459
"InnoDB: Then delete the existing log files."
1460
" Edit the .cnf file\n"
1406
1461
"InnoDB: and start the database again.\n");
1408
1463
return(DB_ERROR);
1424
1479
|| max_arch_log_no != min_arch_log_no
1425
1480
#endif /* UNIV_LOG_ARCHIVE */
1427
drizzled::errmsg_printf(drizzled::error::ERROR,
1428
"InnoDB: Cannot initialize created log files because\n"
1429
"InnoDB: data files were not in sync with each other\n"
1483
"InnoDB: Cannot initialize created"
1484
" log files because\n"
1485
"InnoDB: data files were not in sync"
1486
" with each other\n"
1430
1487
"InnoDB: or the data files are corrupt.\n");
1432
1489
return(DB_ERROR);
1435
1492
if (max_flushed_lsn < (ib_uint64_t) 1000) {
1436
drizzled::errmsg_printf(drizzled::error::ERROR,
1437
"InnoDB: Cannot initialize created log files because\n"
1438
"InnoDB: data files are corrupt, or new data files were\n"
1439
"InnoDB: created when the database was started previous\n"
1440
"InnoDB: time but the database was not shut down\n"
1441
"InnoDB: normally after that.\n");
1494
"InnoDB: Cannot initialize created"
1495
" log files because\n"
1496
"InnoDB: data files are corrupt,"
1497
" or new data files were\n"
1498
"InnoDB: created when the database"
1499
" was started previous\n"
1500
"InnoDB: time but the database"
1501
" was not shut down\n"
1502
"InnoDB: normally after that.\n");
1443
1504
return(DB_ERROR);
1461
1522
if (create_new_db) {
1462
1523
mtr_start(&mtr);
1464
1524
fsp_header_init(0, sum_of_new_sizes, &mtr);
1466
1526
mtr_commit(&mtr);
1468
/* To maintain backward compatibility we create only
1469
the first rollback segment before the double write buffer.
1470
All the remaining rollback segments will be created later,
1471
after the double write buffer has been created. */
1472
1528
trx_sys_create();
1476
1530
srv_startup_is_before_trx_rollback_phase = FALSE;
1478
1532
#ifdef UNIV_LOG_ARCHIVE
1479
1533
} else if (srv_archive_recovery) {
1480
drizzled::errmsg_printf(drizzled::error::INFO,
1481
"InnoDB: Starting archive recovery from a backup...");
1535
"InnoDB: Starting archive"
1536
" recovery from a backup...\n");
1482
1537
err = recv_recovery_from_archive_start(
1483
1538
min_flushed_lsn, srv_archive_recovery_limit_lsn,
1484
1539
min_arch_log_no);
1551
1604
trx_sys_init_at_db_start();
1553
/* Initialize the fsp free limit global variable in the log
1555
fsp_header_get_free_limit();
1557
/* recv_recovery_from_checkpoint_finish needs trx lists which
1558
are initialized in trx_sys_init_at_db_start(). */
1560
recv_recovery_from_checkpoint_finish();
1561
1606
if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
1562
1607
/* The following call is necessary for the insert
1563
1608
buffer to work with multiple tablespaces. We must
1573
1618
every table in the InnoDB data dictionary that has
1576
We also determine the maximum tablespace id used. */
1621
We also determine the maximum tablespace id used.
1623
TODO: We may have incomplete transactions in the
1624
data dictionary tables. Does that harm the scanning of
1625
the data dictionary below? */
1578
1627
dict_check_tablespaces_and_store_max_id(
1579
1628
recv_needed_recovery);
1582
1631
srv_startup_is_before_trx_rollback_phase = FALSE;
1583
recv_recovery_rollback_active();
1633
/* Initialize the fsp free limit global variable in the log
1635
fsp_header_get_free_limit();
1637
/* recv_recovery_from_checkpoint_finish needs trx lists which
1638
are initialized in trx_sys_init_at_db_start(). */
1640
recv_recovery_from_checkpoint_finish();
1585
1642
/* It is possible that file_format tag has never
1586
1643
been set. In this case we initialize it to minimum
1629
1686
/* fprintf(stderr, "Max allowed record size %lu\n",
1630
1687
page_get_free_space_of_empty() / 2); */
1632
if (trx_doublewrite == NULL) {
1633
/* Create the doublewrite buffer to a new tablespace */
1635
trx_sys_create_doublewrite_buf();
1638
/* Here the double write buffer has already been created and so
1639
any new rollback segments will be allocated after the double
1640
write buffer. The default segment should already exist.
1641
We create the new segments only if it's a new database or
1642
the database was shutdown cleanly. */
1644
/* Note: When creating the extra rollback segments during an upgrade
1645
we violate the latching order, even if the change buffer is empty.
1646
We make an exception in sync0sync.c and check srv_is_being_started
1647
for that violation. It cannot create a deadlock because we are still
1648
running in single threaded mode essentially. Only the IO threads
1649
should be running at this stage. */
1651
trx_sys_create_rsegs(TRX_SYS_N_RSEGS - 1);
1653
/* Create the thread which watches the timeouts for lock waits */
1654
os_thread_create(&srv_lock_timeout_thread, NULL,
1689
/* Create the thread which watches the timeouts for lock waits
1690
and prints InnoDB monitor info */
1692
os_thread_create(&srv_lock_timeout_and_monitor_thread, NULL,
1655
1693
thread_ids + 2 + SRV_MAX_N_IO_THREADS);
1657
1695
/* Create the thread which warns of long semaphore waits */
1658
1696
os_thread_create(&srv_error_monitor_thread, NULL,
1659
1697
thread_ids + 3 + SRV_MAX_N_IO_THREADS);
1661
/* Create the thread which prints InnoDB monitor info */
1662
os_thread_create(&srv_monitor_thread, NULL,
1663
thread_ids + 4 + SRV_MAX_N_IO_THREADS);
1665
1698
srv_is_being_started = FALSE;
1700
if (trx_doublewrite == NULL) {
1701
/* Create the doublewrite buffer to a new tablespace */
1703
trx_sys_create_doublewrite_buf();
1667
1706
err = dict_create_or_check_foreign_constraint_tables();
1669
1708
if (err != DB_SUCCESS) {
1676
1715
os_thread_create(&srv_master_thread, NULL, thread_ids
1677
1716
+ (1 + SRV_MAX_N_IO_THREADS));
1679
/* Currently we allow only a single purge thread. */
1680
ut_a(srv_n_purge_threads == 0 || srv_n_purge_threads == 1);
1682
/* If the user has requested a separate purge thread then
1683
start the purge thread. */
1684
if (srv_n_purge_threads == 1) {
1685
os_thread_create(&srv_purge_thread, NULL, NULL);
1688
1717
#ifdef UNIV_DEBUG
1689
1718
/* buf_debug_prints = TRUE; */
1690
1719
#endif /* UNIV_DEBUG */
1699
1728
if (!srv_auto_extend_last_data_file
1700
1729
&& sum_of_data_file_sizes != tablespace_size_in_header) {
1702
drizzled::errmsg_printf(drizzled::error::ERROR,
1703
"InnoDB: Error: tablespace size stored in header is %lu pages, but the sum of data file sizes is %lu pages.",
1704
(ulong) tablespace_size_in_header,
1705
(ulong) sum_of_data_file_sizes);
1732
"InnoDB: Error: tablespace size"
1733
" stored in header is %lu pages, but\n"
1734
"InnoDB: the sum of data file sizes is %lu pages\n",
1735
(ulong) tablespace_size_in_header,
1736
(ulong) sum_of_data_file_sizes);
1707
1738
if (srv_force_recovery == 0
1708
1739
&& sum_of_data_file_sizes < tablespace_size_in_header) {
1709
1740
/* This is a fatal error, the tail of a tablespace is
1712
drizzled::errmsg_printf(drizzled::error::ERROR,
1713
"InnoDB: Cannot start InnoDB. The tail of the system tablespace is "
1714
"missing. Have you edited innodb_data_file_path in my.cnf in an "
1715
"inappropriate way, removing ibdata files from there? "
1716
"You can set innodb_force_recovery=1 in my.cnf to force "
1717
"a startup if you are trying to recover a badly corrupt database.");
1744
"InnoDB: Cannot start InnoDB."
1745
" The tail of the system tablespace is\n"
1746
"InnoDB: missing. Have you edited"
1747
" innodb_data_file_path in my.cnf in an\n"
1748
"InnoDB: inappropriate way, removing"
1749
" ibdata files from there?\n"
1750
"InnoDB: You can set innodb_force_recovery=1"
1751
" in my.cnf to force\n"
1752
"InnoDB: a startup if you are trying"
1753
" to recover a badly corrupt database.\n");
1719
1755
return(DB_ERROR);
1723
1759
if (srv_auto_extend_last_data_file
1724
1760
&& sum_of_data_file_sizes < tablespace_size_in_header) {
1726
drizzled::errmsg_printf(drizzled::error::ERROR,
1727
"InnoDB: Error: tablespace size stored in header is %lu pages, but the sum of data file sizes"
1728
" is only %lu pages\n",
1729
(ulong) tablespace_size_in_header,
1730
(ulong) sum_of_data_file_sizes);
1763
"InnoDB: Error: tablespace size stored in header"
1764
" is %lu pages, but\n"
1765
"InnoDB: 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);
1732
1770
if (srv_force_recovery == 0) {
1734
drizzled::errmsg_printf(drizzled::error::ERROR,
1735
"InnoDB: Cannot start InnoDB. The tail of the system tablespace is "
1736
"missing. Have you edited innodb_data_file_path in my.cnf in an "
1737
"inappropriate way, removing ibdata files from there? "
1738
"You can set innodb_force_recovery=1 in my.cnf to force "
1739
"a startup if you are trying to recover a badly corrupt database.\n");
1773
"InnoDB: Cannot start InnoDB. The tail of"
1774
" the system tablespace is\n"
1775
"InnoDB: missing. Have you edited"
1776
" innodb_data_file_path in my.cnf in an\n"
1777
"InnoDB: inappropriate way, removing"
1778
" ibdata files from there?\n"
1779
"InnoDB: You can set innodb_force_recovery=1"
1780
" in my.cnf to force\n"
1781
"InnoDB: a startup if you are trying to"
1782
" recover a badly corrupt database.\n");
1741
1784
return(DB_ERROR);
1760
1805
os_fast_mutex_free(&srv_os_test_mutex);
1762
1807
if (srv_print_verbose_log) {
1763
drizzled::errmsg_printf(drizzled::error::ERROR,
1764
"InnoDB %s started; log sequence number %"PRIu64"\n",
1765
INNODB_VERSION_STR, srv_start_lsn);
1808
ut_print_timestamp(stderr);
1810
" InnoDB Plugin %s started; "
1811
"log sequence number %"PRIu64"\n",
1812
INNODB_VERSION_STR, srv_start_lsn);
1768
1815
if (srv_force_recovery > 0) {
1769
drizzled::errmsg_printf(drizzled::error::ERROR,
1770
"InnoDB: !!! innodb_force_recovery is set to %lu !!!\n",
1771
(ulong) srv_force_recovery);
1817
"InnoDB: !!! innodb_force_recovery"
1818
" is set to %lu !!!\n",
1819
(ulong) srv_force_recovery);
1774
1824
if (trx_doublewrite_must_reset_space_ids) {
1775
1825
/* Actually, we did not change the undo log format between
1776
1826
4.0 and 4.1.1, and we would not need to run purge to
1785
1835
4.1.1. It is essential that the insert buffer is emptied
1788
drizzled::errmsg_printf(drizzled::error::INFO,
1789
"InnoDB: You are upgrading to an InnoDB version which allows multiple. "
1790
"tablespaces. Wait that purge and insert buffer merge run to completion...");
1839
"InnoDB: You are upgrading to an"
1840
" InnoDB version which allows multiple\n"
1841
"InnoDB: tablespaces. Wait that purge"
1842
" and insert buffer merge run to\n"
1843
"InnoDB: completion...\n");
1792
1845
os_thread_sleep(1000000);
1802
drizzled::errmsg_printf(drizzled::error::INFO,
1803
"InnoDB: Full purge and insert buffer merge completed.");
1856
"InnoDB: Full purge and insert buffer merge"
1805
1859
trx_sys_mark_upgraded_to_multiple_tablespaces();
1807
drizzled::errmsg_printf(drizzled::error::INFO,
1808
"InnoDB: You have now successfully upgraded"
1809
" to the multiple tablespaces\n"
1810
"InnoDB: format. You should NOT DOWNGRADE"
1811
" to an earlier version of\n"
1812
"InnoDB: InnoDB! But if you absolutely need to"
1814
"InnoDB: " REFMAN "multiple-tablespaces.html\n"
1815
"InnoDB: for instructions.\n");
1862
"InnoDB: You have now successfully upgraded"
1863
" to the multiple tablespaces\n"
1864
"InnoDB: format. You should NOT DOWNGRADE"
1865
" to an earlier version of\n"
1866
"InnoDB: InnoDB! But if you absolutely need to"
1868
"InnoDB: " REFMAN "multiple-tablespaces.html\n"
1869
"InnoDB: for instructions.\n");
1818
1872
if (srv_force_recovery == 0) {
1840
1894
/*=============================*/
1898
extern ibool panic_shutdown;
1843
1900
if (!srv_was_started) {
1844
1901
if (srv_is_being_started) {
1845
drizzled::errmsg_printf(drizzled::error::ERROR,
1846
"InnoDB: Warning: shutting down a not properly started or created database!");
1902
ut_print_timestamp(stderr);
1904
" InnoDB: Warning: shutting down"
1905
" a not properly started\n"
1906
"InnoDB: or created database!\n");
1849
1909
return(DB_SUCCESS);
1858
1918
if (srv_fast_shutdown == 2) {
1859
drizzled::errmsg_printf(drizzled::error::INFO,
1860
"InnoDB: MySQL has requested a very fast shutdown without flushing "
1861
"the InnoDB buffer pool to data files. At the next mysqld startup "
1862
"InnoDB will do a crash recovery!");
1919
ut_print_timestamp(stderr);
1921
" InnoDB: MySQL has requested a very fast shutdown"
1922
" without flushing "
1923
"the InnoDB buffer pool to data files."
1924
" At the next mysqld startup "
1925
"InnoDB will do a crash recovery!\n");
1865
logs_empty_and_mark_files_at_shutdown();
1929
if (!panic_shutdown)
1931
logs_empty_and_mark_files_at_shutdown();
1867
1933
if (srv_conc_n_threads != 0) {
1868
drizzled::errmsg_printf(drizzled::error::WARN,
1869
"InnoDB: Warning: query counter shows %ld queries still InnoDB: inside InnoDB at shutdown.",
1870
srv_conc_n_threads);
1935
"InnoDB: Warning: query counter shows %ld queries"
1937
"InnoDB: inside InnoDB at shutdown\n",
1938
srv_conc_n_threads);
1873
1941
/* 2. Make all threads created by InnoDB to exit */
1912
1977
/* All the threads have exited or are just exiting;
1913
1978
NOTE that the threads may not have completed their
1914
1979
exit yet. Should we use pthread_join() to make sure
1915
they have exited? If we did, we would have to
1916
remove the pthread_detach() from
1917
os_thread_exit(). Now we just sleep 0.1
1918
seconds and hope that is enough! */
1980
they have exited? Now we just sleep 0.1 seconds and
1981
hope that is enough! */
1920
1983
os_mutex_exit(os_sync_mutex);
1953
2017
srv_misc_tmpfile = 0;
1956
/* This must be disabled before closing the buffer pool
1957
and closing the data dictionary. */
1958
btr_search_disable();
1964
2020
trx_sys_file_format_close();
1967
2022
mutex_free(&srv_monitor_file_mutex);
1968
2023
mutex_free(&srv_dict_tmpfile_mutex);
1969
2024
mutex_free(&srv_misc_tmpfile_mutex);
1971
btr_search_sys_free();
1973
2026
/* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
2030
/* 4. Free the os_conc_mutex and all os_events and os_mutexes */
1980
/* 4. Free the os_conc_mutex and all os_events and os_mutexes */
1982
2033
os_sync_free();
1984
/* 5. Free all allocated memory */
1988
buf_pool_free(srv_buf_pool_instances);
1991
/* ut_free_all_mem() frees all allocated memory not freed yet
1992
in shutdown, and it will also free the ut_list_mutex, so it
1993
should be the last one for all operation */
2035
/* Check that all read views are closed except read view owned
2038
if (UT_LIST_GET_LEN(trx_sys->view_list) > 1) {
2040
"InnoDB: Error: all read views were not closed"
2041
" before shutdown:\n"
2042
"InnoDB: %lu read views open \n",
2043
UT_LIST_GET_LEN(trx_sys->view_list) - 1);
2046
/* 5. Free all allocated memory and the os_fast_mutex created in
1994
2050
ut_free_all_mem();
1996
2052
if (os_thread_count != 0
1997
2053
|| os_event_count != 0
1998
2054
|| os_mutex_count != 0
1999
2055
|| os_fast_mutex_count != 0) {
2000
drizzled::errmsg_printf(drizzled::error::WARN,
2001
"InnoDB: Warning: some resources were not cleaned up in shutdown:\n"
2002
"InnoDB: threads %lu, events %lu, os_mutexes %lu, os_fast_mutexes %lu\n",
2003
(ulong) os_thread_count, (ulong) os_event_count,
2004
(ulong) os_mutex_count, (ulong) os_fast_mutex_count);
2057
"InnoDB: Warning: some resources were not"
2058
" cleaned up in shutdown:\n"
2059
"InnoDB: threads %lu, events %lu,"
2060
" os_mutexes %lu, os_fast_mutexes %lu\n",
2061
(ulong) os_thread_count, (ulong) os_event_count,
2062
(ulong) os_mutex_count, (ulong) os_fast_mutex_count);
2007
2065
if (dict_foreign_err_file) {
2014
2072
if (srv_print_verbose_log) {
2015
drizzled::errmsg_printf(drizzled::error::INFO,
2016
"InnoDB: Shutdown completed log sequence number %"PRIu64,
2073
ut_print_timestamp(stderr);
2075
" InnoDB: Shutdown completed;"
2076
" log sequence number %"PRIu64"\n",
2020
2080
srv_was_started = FALSE;
2021
srv_start_has_been_called = FALSE;
2023
2082
return((int) DB_SUCCESS);
2086
void set_panic_flag_for_netware()
2088
extern ibool panic_shutdown;
2089
panic_shutdown = TRUE;
2091
#endif /* __NETWARE__ */
2025
2092
#endif /* !UNIV_HOTBACKUP */