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
135
/** Files comprising the system tablespace */
127
136
static os_file_t files[1000];
138
/** Mutex protecting the ios count */
139
static mutex_t ios_mutex;
140
/** Count of I/O operations in io_handler_thread() */
129
143
/** io_handler_thread parameters for thread identification */
130
static ulint n[SRV_MAX_N_IO_THREADS + 6];
144
static ulint n[SRV_MAX_N_IO_THREADS + 5];
131
145
/** io_handler_thread identifiers */
132
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6];
146
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 5];
134
148
/** We use this mutex to test the return value of pthread_mutex_trylock
135
149
on successful locking. HP-UX does NOT return 0, though Linux et al do. */
143
157
#define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD
144
158
#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
161
/*********************************************************************//**
156
162
Convert a numeric string that optionally ends in G or M, to a number
483
486
fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,
484
487
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
490
fil_aio_wait(segment);
492
mutex_enter(&ios_mutex);
494
mutex_exit(&ios_mutex);
495
497
/* We count the number of threads in os_thread_exit(). A created
496
498
thread should always use that to exit and not use return() to exit.
497
499
The thread actually never comes here because it is exited in an
498
500
os_event_wait(). */
501
#if (!defined(__SUNPRO_C) && !defined(__SUNPRO_CC))
501
505
#endif /* !UNIV_HOTBACKUP */
532
/*********************************************************************//**
533
Adds a slash or a backslash to the end of a string if it is missing
534
and the string is not empty.
535
@return string which has the separator if the string is not empty */
538
srv_add_path_separator_if_needed(
539
/*=============================*/
540
char* str) /*!< in: null-terminated character string */
543
ulint len = ut_strlen(str);
545
if (len == 0 || str[len - 1] == SRV_PATH_SEPARATOR) {
550
out_str = ut_malloc(len + 2);
551
memcpy(out_str, str, len);
552
out_str[len] = SRV_PATH_SEPARATOR;
553
out_str[len + 1] = 0;
528
558
#ifndef UNIV_HOTBACKUP
529
559
/*********************************************************************//**
530
560
Calculates the low 32 bits when a file size which is given as a number
575
605
char name[10000];
578
607
UT_NOT_USED(create_new_db);
580
609
*log_file_created = FALSE;
582
611
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,
612
srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed(
613
srv_log_group_home_dirs[k]);
615
ut_a(strlen(srv_log_group_home_dirs[k])
616
< (sizeof name) - 10 - sizeof "ib_logfile");
617
sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k],
618
"ib_logfile", (ulong) i);
620
files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL,
597
621
OS_LOG_FILE, &ret);
598
622
if (ret == FALSE) {
599
623
if (os_file_get_last_error(FALSE) != OS_FILE_ALREADY_EXISTS
604
628
&& os_file_get_last_error(FALSE) != 100
607
drizzled::errmsg_printf(drizzled::error::ERROR,
608
"InnoDB: Error in creating or opening %s", name);
632
"InnoDB: Error in creating"
633
" or opening %s\n", name);
613
files[i] = os_file_create(innodb_file_log_key, name,
614
OS_FILE_OPEN, OS_FILE_AIO,
638
files[i] = os_file_create(name, OS_FILE_OPEN, OS_FILE_AIO,
615
639
OS_LOG_FILE, &ret);
617
drizzled::errmsg_printf(drizzled::error::ERROR,
618
"InnoDB: Error in opening %s.", name);
642
"InnoDB: Error in opening %s\n", name);
620
644
return(DB_ERROR);
626
650
if (size != srv_calc_low32(srv_log_file_size)
627
651
|| 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));
654
"InnoDB: Error: log file %s is"
655
" of different size %lu %lu bytes\n"
656
"InnoDB: than specified in the .cnf"
657
" file %lu %lu bytes!\n",
658
name, (ulong) size_high, (ulong) size,
659
(ulong) srv_calc_high32(srv_log_file_size),
660
(ulong) srv_calc_low32(srv_log_file_size));
636
662
return(DB_ERROR);
639
665
*log_file_created = TRUE;
641
drizzled::errmsg_printf(drizzled::error::INFO,
642
"InnoDB: Log file %s did not exist: new to be created",
667
ut_print_timestamp(stderr);
670
" InnoDB: Log file %s did not exist:"
671
" new to be created\n",
644
673
if (log_file_has_been_opened) {
646
675
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));
678
fprintf(stderr, "InnoDB: Setting log file %s size to %lu MB\n",
679
name, (ulong) srv_log_file_size
680
>> (20 - UNIV_PAGE_SIZE_SHIFT));
654
drizzled::errmsg_printf(drizzled::error::INFO,
655
"InnoDB: Database physically writes the file full: wait...\n");
683
"InnoDB: Database physically writes the file"
657
686
ret = os_file_set_size(name, files[i],
658
687
srv_calc_low32(srv_log_file_size),
659
688
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",
691
"InnoDB: Error in creating %s:"
692
" probably out of disk space\n",
665
695
return(DB_ERROR);
748
778
*create_new_db = FALSE;
750
780
srv_normalize_path_for_win(srv_data_home);
781
srv_data_home = srv_add_path_separator_if_needed(srv_data_home);
752
783
for (i = 0; i < srv_n_data_files; i++) {
755
784
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])
786
ut_a(strlen(srv_data_home) + strlen(srv_data_file_names[i])
759
787
< (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]);
788
sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]);
768
790
if (srv_data_file_is_raw_partition[i] == 0) {
770
792
/* First we try to create the file: if it already
771
793
exists, ret will get value FALSE */
773
files[i] = os_file_create(innodb_file_data_key,
774
name, OS_FILE_CREATE,
795
files[i] = os_file_create(name, OS_FILE_CREATE,
776
797
OS_DATA_FILE, &ret);
797
819
srv_start_raw_disk_in_use = TRUE;
798
820
srv_created_new_raw = TRUE;
800
files[i] = os_file_create(innodb_file_data_key,
801
name, OS_FILE_OPEN_RAW,
822
files[i] = os_file_create(name, OS_FILE_OPEN_RAW,
803
824
OS_DATA_FILE, &ret);
805
drizzled::errmsg_printf(drizzled::error::ERROR,
806
"InnoDB: Error in opening %s", name);
827
"InnoDB: Error in opening %s\n", name);
808
829
return(DB_ERROR);
819
840
/* We open the data file */
821
842
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.",
844
"InnoDB: Error: data files can only"
845
" be added at the end\n");
847
"InnoDB: of a tablespace, but"
848
" data file %s existed beforehand.\n",
826
850
return(DB_ERROR);
829
853
if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
830
854
files[i] = os_file_create(
831
innodb_file_data_key,
832
855
name, OS_FILE_OPEN_RAW,
833
856
OS_FILE_NORMAL, OS_DATA_FILE, &ret);
834
857
} else if (i == 0) {
835
858
files[i] = os_file_create(
836
innodb_file_data_key,
837
859
name, OS_FILE_OPEN_RETRY,
838
860
OS_FILE_NORMAL, OS_DATA_FILE, &ret);
840
862
files[i] = os_file_create(
841
innodb_file_data_key,
842
863
name, OS_FILE_OPEN, OS_FILE_NORMAL,
843
864
OS_DATA_FILE, &ret);
847
drizzled::errmsg_printf(drizzled::error::ERROR,
848
"InnoDB: Error in opening %s", name);
869
"InnoDB: Error in opening %s\n", name);
849
870
os_file_get_last_error(TRUE);
851
872
return(DB_ERROR);
872
893
&& srv_last_file_size_max
873
894
< 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);
897
"InnoDB: Error: auto-extending"
899
" of a different size\n"
900
"InnoDB: %lu pages (rounded"
901
" down to MB) than specified"
902
" in the .cnf file:\n"
903
"InnoDB: initial %lu pages,"
904
" max %lu (relevant if"
905
" non-zero) pages!\n",
907
(ulong) rounded_size_pages,
908
(ulong) srv_data_file_sizes[i],
910
srv_last_file_size_max);
885
912
return(DB_ERROR);
891
918
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!",
921
"InnoDB: Error: data file %s"
922
" is of a different size\n"
924
" (rounded down to MB)\n"
925
"InnoDB: than specified"
926
" in the .cnf file %lu pages!\n",
898
928
(ulong) rounded_size_pages,
899
929
(ulong) srv_data_file_sizes[i]);
915
945
one_created = TRUE;
918
drizzled::errmsg_printf(drizzled::error::INFO,
919
" InnoDB: Data file %s did not exist: new to be created",
948
ut_print_timestamp(stderr);
950
" InnoDB: Data file %s did not"
951
" 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);
955
"InnoDB: The first specified"
956
" data file %s did not exist:\n"
957
"InnoDB: a new database"
958
" to be created!\n", name);
924
959
*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)));
962
ut_print_timestamp(stderr);
964
" InnoDB: Setting file %s size to %lu MB\n",
966
(ulong) (srv_data_file_sizes[i]
967
>> (20 - UNIV_PAGE_SIZE_SHIFT)));
932
drizzled::errmsg_printf(drizzled::error::INFO,
933
"InnoDB: Database physically writes the file full: wait...");
970
"InnoDB: Database physically writes the"
971
" file full: wait...\n");
935
973
ret = os_file_set_size(
1003
1047
on Mac OS X 10.3 or later. */
1004
1048
struct utsname utsname;
1005
1049
if (uname(&utsname)) {
1006
fputs(_("InnoDB: cannot determine Mac OS X version!\n"), stderr);
1050
fputs("InnoDB: cannot determine Mac OS X version!\n", stderr);
1008
1052
srv_have_fullfsync = strcmp(utsname.release, "7.") >= 0;
1010
1054
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);
1055
fputs("InnoDB: On Mac OS X, fsync() may be"
1056
" broken on internal drives,\n"
1057
"InnoDB: making transactions unsafe!\n", stderr);
1015
1059
# endif /* F_FULLFSYNC */
1016
1060
#endif /* HAVE_DARWIN_THREADS */
1018
1062
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."),
1064
"InnoDB: Error: size of InnoDB's ulint is %lu,"
1065
" but size of void* is %lu.\n"
1066
"InnoDB: The sizes should be the same"
1067
" so that on a 64-bit platform you can\n"
1068
"InnoDB: allocate more than 4 GB of memory.",
1022
1069
(ulong)sizeof(ulint), (ulong)sizeof(void*));
1028
1075
innodb_file_per_table) until this function has returned. */
1029
1076
srv_file_per_table = FALSE;
1030
1077
#ifdef UNIV_DEBUG
1031
drizzled::errmsg_printf(drizzled::error::INFO,
1032
_("InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n"));
1079
"InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n");
1035
1082
#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"
1084
"InnoDB: !!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!\n"
1085
"InnoDB: Crash recovery will fail with UNIV_IBUF_DEBUG\n");
1045
1088
#ifdef UNIV_SYNC_DEBUG
1046
drizzled::errmsg_printf(drizzled::error::INFO,
1047
_("InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n"));
1090
"InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n");
1050
1093
#ifdef UNIV_SEARCH_DEBUG
1051
drizzled::errmsg_printf(drizzled::error::INFO,
1052
_("InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n"));
1095
"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
1098
#ifdef UNIV_MEM_DEBUG
1060
drizzled::errmsg_printf(drizzled::error::INFO,
1061
_("InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n"));
1100
"InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n");
1064
if (UNIV_LIKELY(srv_use_sys_malloc))
1066
drizzled::errmsg_printf(drizzled::error::INFO, _("InnoDB: The InnoDB memory heap is disabled\n"));
1103
if (UNIV_LIKELY(srv_use_sys_malloc)) {
1105
"InnoDB: The InnoDB memory heap is disabled\n");
1069
drizzled::errmsg_printf(drizzled::error::INFO, "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 */
1108
#ifdef HAVE_GCC_ATOMIC_BUILTINS
1109
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1111
"InnoDB: Mutexes and rw_locks use GCC atomic builtins.\n");
1112
# else /* INNODB_RW_LOCKS_USE_ATOMICS */
1114
"InnoDB: Mutexes use GCC atomic builtins, rw_locks do not.\n");
1115
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1116
#elif defined(HAVE_SOLARIS_ATOMICS)
1117
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1119
"InnoDB: Mutexes and rw_locks use Solaris atomic functions.\n");
1122
"InnoDB: Mutexes use Solaris atomic functions.\n");
1123
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1124
#elif defined(HAVE_WINDOWS_ATOMICS)
1125
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1127
"InnoDB: Mutexes and rw_locks use Windows interlocked functions.\n");
1130
"InnoDB: Mutexes use Windows interlocked functions.\n");
1131
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1132
#else /* HAVE_GCC_ATOMIC_BUILTINS */
1134
"InnoDB: Neither mutexes nor rw_locks use GCC atomic builtins.\n");
1135
#endif /* HAVE_GCC_ATOMIC_BUILTINS */
1080
1137
/* Since InnoDB does not currently clean up all its internal data
1081
1138
structures in MySQL Embedded Server Library server_end(), we
1083
1140
second time during the process lifetime. */
1085
1142
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");
1144
"InnoDB: Error:startup called second time"
1145
" during the process lifetime.\n"
1146
"InnoDB: In the MySQL Embedded Server Library"
1147
" you cannot call server_init()\n"
1148
"InnoDB: more than once during"
1149
" the process lifetime.\n");
1090
1152
srv_start_has_been_called = TRUE;
1107
1170
but when run in conjunction with InnoDB Hot Backup, it seemed
1108
1171
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;
1173
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;
1176
/* On Win 2000 and XP use async i/o */
1177
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
1181
if (srv_file_flush_method_str == NULL) {
1141
1182
/* These are the default options */
1162
1203
} else if (0 == ut_strcmp(srv_file_flush_method_str, "normal")) {
1163
1204
srv_win_file_flush_method = SRV_WIN_IO_NORMAL;
1164
srv_use_native_aio = FALSE;
1205
os_aio_use_native_aio = FALSE;
1166
1207
} else if (0 == ut_strcmp(srv_file_flush_method_str, "unbuffered")) {
1167
1208
srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
1168
srv_use_native_aio = FALSE;
1209
os_aio_use_native_aio = FALSE;
1170
1211
} else if (0 == ut_strcmp(srv_file_flush_method_str,
1171
1212
"async_unbuffered")) {
1172
1213
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);
1217
"InnoDB: Unrecognized value %s for"
1218
" innodb_flush_method\n",
1219
srv_file_flush_method_str);
1178
1220
return(DB_ERROR);
1186
1228
maximum number of threads that can wait in the 'srv_conc array' for
1187
1229
their time to enter InnoDB. */
1231
#if defined(__NETWARE__)
1233
/* Create less event semaphores because Win 98/ME had
1234
difficulty creating 40000 event semaphores. Comment from
1235
Novell, Inc.: also, these just take a lot of memory on
1237
srv_max_n_threads = 1000;
1189
1239
if (srv_buf_pool_size >= 1000 * 1024 * 1024) {
1190
1240
/* If buffer pool is less than 1000 MB,
1191
assume fewer threads. Also use only one
1192
buffer pool instance */
1241
assume fewer threads. */
1193
1242
srv_max_n_threads = 50000;
1195
1244
} else if (srv_buf_pool_size >= 8 * 1024 * 1024) {
1197
srv_buf_pool_instances = 1;
1198
1246
srv_max_n_threads = 10000;
1200
srv_buf_pool_instances = 1;
1201
1248
srv_max_n_threads = 1000; /* saves several MB of memory,
1202
1249
especially in 64-bit
1206
1253
err = srv_boot();
1208
1255
if (err != DB_SUCCESS) {
1210
1257
return((int) err);
1213
mutex_create(srv_monitor_file_mutex_key,
1214
&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
1260
mutex_create(&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
1216
1262
if (srv_innodb_status) {
1217
srv_monitor_file_name = static_cast<char *>(mem_alloc(
1263
srv_monitor_file_name = mem_alloc(
1218
1264
strlen(fil_path_to_mysql_datadir)
1219
+ 20 + sizeof "/innodb_status."));
1265
+ 20 + sizeof "/innodb_status.");
1220
1266
sprintf(srv_monitor_file_name, "%s/innodb_status.%lu",
1221
1267
fil_path_to_mysql_datadir, os_proc_get_number());
1222
1268
srv_monitor_file = fopen(srv_monitor_file_name, "w+");
1223
1269
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));
1270
fprintf(stderr, "InnoDB: unable to create %s: %s\n",
1271
srv_monitor_file_name, strerror(errno));
1226
1272
return(DB_ERROR);
1236
mutex_create(srv_dict_tmpfile_mutex_key,
1237
&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1282
mutex_create(&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1239
1284
srv_dict_tmpfile = os_file_create_tmpfile();
1240
1285
if (!srv_dict_tmpfile) {
1241
1286
return(DB_ERROR);
1244
mutex_create(srv_misc_tmpfile_mutex_key,
1245
&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1289
mutex_create(&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1247
1291
srv_misc_tmpfile = os_file_create_tmpfile();
1248
1292
if (!srv_misc_tmpfile) {
1249
1293
return(DB_ERROR);
1252
/* innodb_file_io_threads used to be user settable.
1253
It is now just a combination of read_io_threads and
1254
write_io_threads that is set by innodb internally. */
1296
/* If user has set the value of innodb_file_io_threads then
1297
we'll emit a message telling the user that this parameter
1298
is now deprecated. */
1299
if (srv_n_file_io_threads != 4) {
1300
fprintf(stderr, "InnoDB: Warning:"
1301
" innodb_file_io_threads is deprecated."
1302
" Please use innodb_read_io_threads and"
1303
" innodb_write_io_threads instead\n");
1256
1306
/* Now overwrite the value on srv_n_file_io_threads */
1257
1307
srv_n_file_io_threads = 2 + srv_n_read_io_threads
1275
1325
fil_init(srv_file_per_table ? 50000 : 5000,
1276
1326
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");
1328
ret = buf_pool_init();
1332
"InnoDB: Fatal error: cannot allocate the memory"
1333
" for the buffer pool\n");
1298
1338
#ifdef UNIV_DEBUG
1302
1342
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);
1344
fprintf(stderr, "InnoDB: Warning: Small buffer pool size "
1345
"(%luM), the flst_validate() debug function "
1346
"can cause a deadlock if the buffer pool fills up.\n",
1347
srv_buf_pool_size / 1024 / 1024);
1324
1364
#ifdef UNIV_LOG_ARCHIVE
1325
1365
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.");
1367
"InnoDB: Error: you must set the log group"
1368
" home dir in my.cnf the\n"
1369
"InnoDB: same as log arch dir.\n");
1329
1371
return(DB_ERROR);
1331
1373
#endif /* UNIV_LOG_ARCHIVE */
1333
1375
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");
1377
"InnoDB: Error: combined size of log files"
1378
" must be < 4 GB\n");
1337
1380
return(DB_ERROR);
1342
1385
for (i = 0; i < srv_n_data_files; i++) {
1343
1386
#ifndef __WIN__
1344
1387
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");
1389
"InnoDB: Error: file size must be < 4 GB"
1390
" with this MySQL binary\n"
1391
"InnoDB: and operating system combination,"
1392
" in some OS's < 2 GB\n");
1349
1394
return(DB_ERROR);
1365
1412
&min_flushed_lsn, &max_flushed_lsn,
1366
1413
&sum_of_new_sizes);
1367
1414
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");
1416
"InnoDB: Could not open or create data files.\n"
1417
"InnoDB: If you tried to add new data files,"
1418
" and it failed here,\n"
1419
"InnoDB: you should now edit innodb_data_file_path"
1421
"InnoDB: to what it was, and remove the"
1422
" new ibdata files InnoDB created\n"
1423
"InnoDB: in this failed attempt. InnoDB only wrote"
1424
" those files full of\n"
1425
"InnoDB: zeros, but did not yet use them in any way."
1426
" But be careful: do not\n"
1427
"InnoDB: remove old data files"
1428
" which contain your precious data!\n");
1377
1430
return((int) err);
1398
1451
if ((log_opened && create_new_db)
1399
1452
|| (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"
1454
"InnoDB: Error: all log files must be"
1455
" created at the same time.\n"
1456
"InnoDB: All log files must be"
1457
" created also in database creation.\n"
1458
"InnoDB: If you want bigger or smaller"
1459
" log files, shut down the\n"
1460
"InnoDB: database and make sure there"
1461
" were no errors in shutdown.\n"
1462
"InnoDB: Then delete the existing log files."
1463
" Edit the .cnf file\n"
1406
1464
"InnoDB: and start the database again.\n");
1408
1466
return(DB_ERROR);
1424
1482
|| max_arch_log_no != min_arch_log_no
1425
1483
#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"
1486
"InnoDB: Cannot initialize created"
1487
" log files because\n"
1488
"InnoDB: data files were not in sync"
1489
" with each other\n"
1430
1490
"InnoDB: or the data files are corrupt.\n");
1432
1492
return(DB_ERROR);
1435
1495
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");
1497
"InnoDB: Cannot initialize created"
1498
" log files because\n"
1499
"InnoDB: data files are corrupt,"
1500
" or new data files were\n"
1501
"InnoDB: created when the database"
1502
" was started previous\n"
1503
"InnoDB: time but the database"
1504
" was not shut down\n"
1505
"InnoDB: normally after that.\n");
1443
1507
return(DB_ERROR);
1461
1525
if (create_new_db) {
1462
1526
mtr_start(&mtr);
1464
1527
fsp_header_init(0, sum_of_new_sizes, &mtr);
1466
1529
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
1531
trx_sys_create();
1476
1533
srv_startup_is_before_trx_rollback_phase = FALSE;
1478
1535
#ifdef UNIV_LOG_ARCHIVE
1479
1536
} else if (srv_archive_recovery) {
1480
drizzled::errmsg_printf(drizzled::error::INFO,
1481
"InnoDB: Starting archive recovery from a backup...");
1538
"InnoDB: Starting archive"
1539
" recovery from a backup...\n");
1482
1540
err = recv_recovery_from_archive_start(
1483
1541
min_flushed_lsn, srv_archive_recovery_limit_lsn,
1484
1542
min_arch_log_no);
1551
1607
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
1609
if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
1562
1610
/* The following call is necessary for the insert
1563
1611
buffer to work with multiple tablespaces. We must
1573
1621
every table in the InnoDB data dictionary that has
1576
We also determine the maximum tablespace id used. */
1624
We also determine the maximum tablespace id used.
1626
TODO: We may have incomplete transactions in the
1627
data dictionary tables. Does that harm the scanning of
1628
the data dictionary below? */
1578
1630
dict_check_tablespaces_and_store_max_id(
1579
1631
recv_needed_recovery);
1582
1634
srv_startup_is_before_trx_rollback_phase = FALSE;
1583
recv_recovery_rollback_active();
1636
/* Initialize the fsp free limit global variable in the log
1638
fsp_header_get_free_limit();
1640
/* recv_recovery_from_checkpoint_finish needs trx lists which
1641
are initialized in trx_sys_init_at_db_start(). */
1643
recv_recovery_from_checkpoint_finish();
1585
1645
/* It is possible that file_format tag has never
1586
1646
been set. In this case we initialize it to minimum
1629
1689
/* fprintf(stderr, "Max allowed record size %lu\n",
1630
1690
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,
1692
/* Create the thread which watches the timeouts for lock waits
1693
and prints InnoDB monitor info */
1695
os_thread_create(&srv_lock_timeout_and_monitor_thread, NULL,
1655
1696
thread_ids + 2 + SRV_MAX_N_IO_THREADS);
1657
1698
/* Create the thread which warns of long semaphore waits */
1658
1699
os_thread_create(&srv_error_monitor_thread, NULL,
1659
1700
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
1701
srv_is_being_started = FALSE;
1703
if (trx_doublewrite == NULL) {
1704
/* Create the doublewrite buffer to a new tablespace */
1706
trx_sys_create_doublewrite_buf();
1667
1709
err = dict_create_or_check_foreign_constraint_tables();
1669
1711
if (err != DB_SUCCESS) {
1676
1718
os_thread_create(&srv_master_thread, NULL, thread_ids
1677
1719
+ (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
1720
#ifdef UNIV_DEBUG
1689
1721
/* buf_debug_prints = TRUE; */
1690
1722
#endif /* UNIV_DEBUG */
1699
1731
if (!srv_auto_extend_last_data_file
1700
1732
&& 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);
1735
"InnoDB: Error: tablespace size"
1736
" stored in header is %lu pages, but\n"
1737
"InnoDB: the sum of data file sizes is %lu pages\n",
1738
(ulong) tablespace_size_in_header,
1739
(ulong) sum_of_data_file_sizes);
1707
1741
if (srv_force_recovery == 0
1708
1742
&& sum_of_data_file_sizes < tablespace_size_in_header) {
1709
1743
/* 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.");
1747
"InnoDB: Cannot start InnoDB."
1748
" The tail of the system tablespace is\n"
1749
"InnoDB: missing. Have you edited"
1750
" innodb_data_file_path in my.cnf in an\n"
1751
"InnoDB: inappropriate way, removing"
1752
" ibdata files from there?\n"
1753
"InnoDB: You can set innodb_force_recovery=1"
1754
" in my.cnf to force\n"
1755
"InnoDB: a startup if you are trying"
1756
" to recover a badly corrupt database.\n");
1719
1758
return(DB_ERROR);
1723
1762
if (srv_auto_extend_last_data_file
1724
1763
&& 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);
1766
"InnoDB: Error: tablespace size stored in header"
1767
" is %lu pages, but\n"
1768
"InnoDB: the sum of data file sizes"
1769
" is only %lu pages\n",
1770
(ulong) tablespace_size_in_header,
1771
(ulong) sum_of_data_file_sizes);
1732
1773
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");
1776
"InnoDB: Cannot start InnoDB. The tail of"
1777
" the system tablespace is\n"
1778
"InnoDB: missing. Have you edited"
1779
" innodb_data_file_path in my.cnf in an\n"
1780
"InnoDB: inappropriate way, removing"
1781
" ibdata files from there?\n"
1782
"InnoDB: You can set innodb_force_recovery=1"
1783
" in my.cnf to force\n"
1784
"InnoDB: a startup if you are trying to"
1785
" recover a badly corrupt database.\n");
1741
1787
return(DB_ERROR);
1760
1808
os_fast_mutex_free(&srv_os_test_mutex);
1762
1810
if (srv_print_verbose_log) {
1763
drizzled::errmsg_printf(drizzled::error::INFO,
1764
"InnoDB %s started; log sequence number %"PRIu64"\n",
1765
INNODB_VERSION_STR, srv_start_lsn);
1811
ut_print_timestamp(stderr);
1813
" InnoDB Plugin %s started; "
1814
"log sequence number %"PRIu64"\n",
1815
INNODB_VERSION_STR, srv_start_lsn);
1768
1818
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);
1820
"InnoDB: !!! innodb_force_recovery"
1821
" is set to %lu !!!\n",
1822
(ulong) srv_force_recovery);
1774
1827
if (trx_doublewrite_must_reset_space_ids) {
1775
1828
/* Actually, we did not change the undo log format between
1776
1829
4.0 and 4.1.1, and we would not need to run purge to
1785
1838
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...");
1842
"InnoDB: You are upgrading to an"
1843
" InnoDB version which allows multiple\n"
1844
"InnoDB: tablespaces. Wait that purge"
1845
" and insert buffer merge run to\n"
1846
"InnoDB: completion...\n");
1792
1848
os_thread_sleep(1000000);
1802
drizzled::errmsg_printf(drizzled::error::INFO,
1803
"InnoDB: Full purge and insert buffer merge completed.");
1859
"InnoDB: Full purge and insert buffer merge"
1805
1862
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");
1865
"InnoDB: You have now successfully upgraded"
1866
" to the multiple tablespaces\n"
1867
"InnoDB: format. You should NOT DOWNGRADE"
1868
" to an earlier version of\n"
1869
"InnoDB: InnoDB! But if you absolutely need to"
1871
"InnoDB: " REFMAN "multiple-tablespaces.html\n"
1872
"InnoDB: for instructions.\n");
1818
1875
if (srv_force_recovery == 0) {
1840
1897
/*=============================*/
1901
extern ibool panic_shutdown;
1843
1903
if (!srv_was_started) {
1844
1904
if (srv_is_being_started) {
1845
drizzled::errmsg_printf(drizzled::error::ERROR,
1846
"InnoDB: Warning: shutting down a not properly started or created database!");
1905
ut_print_timestamp(stderr);
1907
" InnoDB: Warning: shutting down"
1908
" a not properly started\n"
1909
"InnoDB: or created database!\n");
1849
1912
return(DB_SUCCESS);
1858
1921
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!");
1922
ut_print_timestamp(stderr);
1924
" InnoDB: MySQL has requested a very fast shutdown"
1925
" without flushing "
1926
"the InnoDB buffer pool to data files."
1927
" At the next mysqld startup "
1928
"InnoDB will do a crash recovery!\n");
1865
logs_empty_and_mark_files_at_shutdown();
1932
if (!panic_shutdown)
1934
logs_empty_and_mark_files_at_shutdown();
1867
1936
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);
1938
"InnoDB: Warning: query counter shows %ld queries"
1940
"InnoDB: inside InnoDB at shutdown\n",
1941
srv_conc_n_threads);
1873
1944
/* 2. Make all threads created by InnoDB to exit */
1912
1980
/* All the threads have exited or are just exiting;
1913
1981
NOTE that the threads may not have completed their
1914
1982
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! */
1983
they have exited? Now we just sleep 0.1 seconds and
1984
hope that is enough! */
1920
1986
os_mutex_exit(os_sync_mutex);
1953
2020
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
2023
trx_sys_file_format_close();
1967
2025
mutex_free(&srv_monitor_file_mutex);
1968
2026
mutex_free(&srv_dict_tmpfile_mutex);
1969
2027
mutex_free(&srv_misc_tmpfile_mutex);
1971
btr_search_sys_free();
1973
2029
/* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
2033
/* 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
2036
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 */
2038
/* Check that all read views are closed except read view owned
2041
if (UT_LIST_GET_LEN(trx_sys->view_list) > 1) {
2043
"InnoDB: Error: all read views were not closed"
2044
" before shutdown:\n"
2045
"InnoDB: %lu read views open \n",
2046
UT_LIST_GET_LEN(trx_sys->view_list) - 1);
2049
/* 5. Free all allocated memory and the os_fast_mutex created in
1994
2053
ut_free_all_mem();
1996
2055
if (os_thread_count != 0
1997
2056
|| os_event_count != 0
1998
2057
|| os_mutex_count != 0
1999
2058
|| 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);
2060
"InnoDB: Warning: some resources were not"
2061
" cleaned up in shutdown:\n"
2062
"InnoDB: threads %lu, events %lu,"
2063
" os_mutexes %lu, os_fast_mutexes %lu\n",
2064
(ulong) os_thread_count, (ulong) os_event_count,
2065
(ulong) os_mutex_count, (ulong) os_fast_mutex_count);
2007
2068
if (dict_foreign_err_file) {
2014
2075
if (srv_print_verbose_log) {
2015
drizzled::errmsg_printf(drizzled::error::INFO,
2016
"InnoDB: Shutdown completed log sequence number %"PRIu64,
2076
ut_print_timestamp(stderr);
2078
" InnoDB: Shutdown completed;"
2079
" log sequence number %"PRIu64"\n",
2020
2083
srv_was_started = FALSE;
2021
srv_start_has_been_called = FALSE;
2023
2085
return((int) DB_SUCCESS);
2089
void set_panic_flag_for_netware()
2091
extern ibool panic_shutdown;
2092
panic_shutdown = TRUE;
2094
#endif /* __NETWARE__ */
2025
2095
#endif /* !UNIV_HOTBACKUP */