drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
srv0start.cc
1/*****************************************************************************
2
3Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
4Copyright (C) 2008, Google Inc.
5Copyright (C) 2009, Percona Inc.
6
7Portions of this file contain modifications contributed and copyrighted by
8Google, Inc. Those modifications are gratefully acknowledged and are described
9briefly in the InnoDB documentation. The contributions by Google are
10incorporated with their permission, and subject to the conditions contained in
11the file COPYING.Google.
12
13Portions of this file contain modifications contributed and copyrighted
14by Percona Inc.. Those modifications are
15gratefully acknowledged and are described briefly in the InnoDB
16documentation. The contributions by Percona Inc. are incorporated with
17their permission, and subject to the conditions contained in the file
18COPYING.Percona.
19
20This program is free software; you can redistribute it and/or modify it under
21the terms of the GNU General Public License as published by the Free Software
22Foundation; version 2 of the License.
23
24This program is distributed in the hope that it will be useful, but WITHOUT
25ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
26FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
27
28You should have received a copy of the GNU General Public License along with
29this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
30St, Fifth Floor, Boston, MA 02110-1301 USA
31
32*****************************************************************************/
33
34/********************************************************************/
40
41#include "ut0mem.h"
42#include "mem0mem.h"
43#include "data0data.h"
44#include "data0type.h"
45#include "dict0dict.h"
46#include "buf0buf.h"
47#include "os0file.h"
48#include "os0thread.h"
49#include "fil0fil.h"
50#include "fsp0fsp.h"
51#include "rem0rec.h"
52#include "mtr0mtr.h"
53#include "log0log.h"
54#include "log0recv.h"
55#include "page0page.h"
56#include "page0cur.h"
57#include "trx0trx.h"
58#include "trx0sys.h"
59#include "btr0btr.h"
60#include "btr0cur.h"
61#include "rem0rec.h"
62#include "ibuf0ibuf.h"
63#include "srv0start.h"
64#include "srv0srv.h"
65#ifndef UNIV_HOTBACKUP
66# include "os0proc.h"
67# include "sync0sync.h"
68# include "buf0flu.h"
69# include "buf0rea.h"
70# include "dict0boot.h"
71# include "dict0load.h"
72# include "que0que.h"
73# include "usr0sess.h"
74# include "lock0lock.h"
75# include "trx0roll.h"
76# include "trx0purge.h"
77# include "lock0lock.h"
78# include "pars0pars.h"
79# include "btr0sea.h"
80# include "rem0cmp.h"
81# include "dict0crea.h"
82# include "row0ins.h"
83# include "row0sel.h"
84# include "row0upd.h"
85# include "row0row.h"
86# include "row0mysql.h"
87# include "btr0pcur.h"
88# include "os0sync.h" /* for INNODB_RW_LOCKS_USE_ATOMICS */
89# include "zlib.h" /* for ZLIB_VERSION */
90#include "xtrabackup_api.h"
91
92#include <errno.h>
93#include <unistd.h>
94
95#include <drizzled/gettext.h>
96#include <drizzled/errmsg_print.h>
97
99UNIV_INTERN ib_uint64_t srv_start_lsn;
101UNIV_INTERN ib_uint64_t srv_shutdown_lsn;
102
103#ifdef HAVE_DARWIN_THREADS
104# include <sys/utsname.h>
106UNIV_INTERN ibool srv_have_fullfsync = FALSE;
107#endif
108
110UNIV_INTERN ibool srv_start_raw_disk_in_use = FALSE;
111
116UNIV_INTERN ibool srv_is_being_started = FALSE;
118UNIV_INTERN ibool srv_was_started = FALSE;
120static ibool srv_start_has_been_called = FALSE;
121
125
127static os_file_t files[1000];
128
130static ulint n[SRV_MAX_N_IO_THREADS + 7];
132static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 7];
133
136static os_fast_mutex_t srv_os_test_mutex;
137
139static char* srv_monitor_file_name;
140#endif /* !UNIV_HOTBACKUP */
141
143#define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD
144#define SRV_MAX_N_PENDING_SYNC_IOS 100
145
146#ifdef UNIV_PFS_THREAD
147/* Keys to register InnoDB threads with performance schema */
148UNIV_INTERN mysql_pfs_key_t io_handler_thread_key;
149UNIV_INTERN mysql_pfs_key_t srv_lock_timeout_thread_key;
150UNIV_INTERN mysql_pfs_key_t srv_error_monitor_thread_key;
151UNIV_INTERN mysql_pfs_key_t srv_monitor_thread_key;
152UNIV_INTERN mysql_pfs_key_t srv_master_thread_key;
153#endif /* UNIV_PFS_THREAD */
154
155/*********************************************************************/
159static
160char*
161srv_parse_megabytes(
162/*================*/
163 char* str,
164 ulint* megs)
165{
166 char* endp;
167 ulint size;
168
169 size = strtoul(str, &endp, 10);
170
171 str = endp;
172
173 switch (*str) {
174 case 'G': case 'g':
175 size *= 1024;
176 /* fall through */
177 case 'M': case 'm':
178 str++;
179 break;
180 default:
181 size /= 1024 * 1024;
182 break;
183 }
184
185 *megs = size;
186 return(str);
187}
188
189/*********************************************************************/
193UNIV_INTERN
194ibool
196/*================================*/
197 char* str)
198{
199 char* input_str;
200 char* path;
201 ulint size;
202 ulint i = 0;
203
204 srv_auto_extend_last_data_file = FALSE;
205 srv_last_file_size_max = 0;
206 srv_data_file_names = NULL;
207 srv_data_file_sizes = NULL;
208 srv_data_file_is_raw_partition = NULL;
209
210 input_str = str;
211
212 /* First calculate the number of data files and check syntax:
213 path:size[M | G];path:size[M | G]... . Note that a Windows path may
214 contain a drive name and a ':'. */
215
216 while (*str != '\0') {
217 path = str;
218
219 while ((*str != ':' && *str != '\0')
220 || (*str == ':'
221 && (*(str + 1) == '\\' || *(str + 1) == '/'
222 || *(str + 1) == ':'))) {
223 str++;
224 }
225
226 if (*str == '\0') {
227 return(FALSE);
228 }
229
230 str++;
231
232 str = srv_parse_megabytes(str, &size);
233
234 if (0 == strncmp(str, ":autoextend",
235 (sizeof ":autoextend") - 1)) {
236
237 str += (sizeof ":autoextend") - 1;
238
239 if (0 == strncmp(str, ":max:",
240 (sizeof ":max:") - 1)) {
241
242 str += (sizeof ":max:") - 1;
243
244 str = srv_parse_megabytes(str, &size);
245 }
246
247 if (*str != '\0') {
248
249 return(FALSE);
250 }
251 }
252
253 if (strlen(str) >= 6
254 && *str == 'n'
255 && *(str + 1) == 'e'
256 && *(str + 2) == 'w') {
257 str += 3;
258 }
259
260 if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
261 str += 3;
262 }
263
264 if (size == 0) {
265 return(FALSE);
266 }
267
268 i++;
269
270 if (*str == ';') {
271 str++;
272 } else if (*str != '\0') {
273
274 return(FALSE);
275 }
276 }
277
278 if (i == 0) {
279 /* If innodb_data_file_path was defined it must contain
280 at least one data file definition */
281
282 return(FALSE);
283 }
284
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));
289
290 srv_n_data_files = i;
291
292 /* Then store the actual values to our arrays */
293
294 str = input_str;
295 i = 0;
296
297 while (*str != '\0') {
298 path = str;
299
300 /* Note that we must step over the ':' in a Windows path;
301 a Windows path normally looks like C:\ibdata\ibdata1:1G, but
302 a Windows raw partition may have a specification like
303 \\.\C::1Gnewraw or \\.\PHYSICALDRIVE2:1Gnewraw */
304
305 while ((*str != ':' && *str != '\0')
306 || (*str == ':'
307 && (*(str + 1) == '\\' || *(str + 1) == '/'
308 || *(str + 1) == ':'))) {
309 str++;
310 }
311
312 if (*str == ':') {
313 /* Make path a null-terminated string */
314 *str = '\0';
315 str++;
316 }
317
318 str = srv_parse_megabytes(str, &size);
319
320 srv_data_file_names[i] = path;
321 srv_data_file_sizes[i] = size;
322
323 if (0 == strncmp(str, ":autoextend",
324 (sizeof ":autoextend") - 1)) {
325
326 srv_auto_extend_last_data_file = TRUE;
327
328 str += (sizeof ":autoextend") - 1;
329
330 if (0 == strncmp(str, ":max:",
331 (sizeof ":max:") - 1)) {
332
333 str += (sizeof ":max:") - 1;
334
335 str = srv_parse_megabytes(
336 str, &srv_last_file_size_max);
337 }
338
339 if (*str != '\0') {
340
341 return(FALSE);
342 }
343 }
344
345 (srv_data_file_is_raw_partition)[i] = 0;
346
347 if (strlen(str) >= 6
348 && *str == 'n'
349 && *(str + 1) == 'e'
350 && *(str + 2) == 'w') {
351 str += 3;
352 (srv_data_file_is_raw_partition)[i] = SRV_NEW_RAW;
353 }
354
355 if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
356 str += 3;
357
358 if ((srv_data_file_is_raw_partition)[i] == 0) {
359 (srv_data_file_is_raw_partition)[i] = SRV_OLD_RAW;
360 }
361 }
362
363 i++;
364
365 if (*str == ';') {
366 str++;
367 }
368 }
369
370 return(TRUE);
371}
372
373/*********************************************************************/
377UNIV_INTERN
378ibool
380/*==========================*/
381 char* str)
382{
383 char* input_str;
384 char* path;
385 ulint i = 0;
386
387 srv_log_group_home_dirs = NULL;
388
389 input_str = str;
390
391 /* First calculate the number of directories and check syntax:
392 path;path;... */
393
394 while (*str != '\0') {
395 path = str;
396
397 while (*str != ';' && *str != '\0') {
398 str++;
399 }
400
401 i++;
402
403 if (*str == ';') {
404 str++;
405 } else if (*str != '\0') {
406
407 return(FALSE);
408 }
409 }
410
411 if (i != 1) {
412 /* If innodb_log_group_home_dir was defined it must
413 contain exactly one path definition under current MySQL */
414
415 return(FALSE);
416 }
417
418 srv_log_group_home_dirs = static_cast<char **>(malloc(i * sizeof *srv_log_group_home_dirs));
419
420 /* Then store the actual values to our array */
421
422 str = input_str;
423 i = 0;
424
425 while (*str != '\0') {
426 path = str;
427
428 while (*str != ';' && *str != '\0') {
429 str++;
430 }
431
432 if (*str == ';') {
433 *str = '\0';
434 str++;
435 }
436
437 srv_log_group_home_dirs[i] = path;
438
439 i++;
440 }
441
442 return(TRUE);
443}
444
445/*********************************************************************/
448UNIV_INTERN
449void
451/*==========================*/
452{
453 free(srv_data_file_names);
454 srv_data_file_names = NULL;
455 free(srv_data_file_sizes);
456 srv_data_file_sizes = NULL;
457 free(srv_data_file_is_raw_partition);
458 srv_data_file_is_raw_partition = NULL;
459 free(srv_log_group_home_dirs);
460 srv_log_group_home_dirs = NULL;
461}
462
463#ifndef UNIV_HOTBACKUP
464/********************************************************************/
467extern "C"
468os_thread_ret_t
469io_handler_thread(void* arg);
470
471extern "C"
472os_thread_ret_t
473io_handler_thread(
474/*==============*/
475 void* arg)
477{
478 ulint segment;
479
480 segment = *((ulint*)arg);
481
482#ifdef UNIV_DEBUG_THREAD_CREATION
483 fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,
485#endif
486
487#ifdef UNIV_PFS_THREAD
488 pfs_register_thread(io_handler_thread_key);
489#endif /* UNIV_PFS_THREAD */
490
492 fil_aio_wait(segment);
493 }
494
495 /* We count the number of threads in os_thread_exit(). A created
496 thread should always use that to exit and not use return() to exit.
497 The thread actually never comes here because it is exited in an
498 os_event_wait(). */
499 return 0;
500}
501#endif /* !UNIV_HOTBACKUP */
502
503#ifdef __WIN__
504#define SRV_PATH_SEPARATOR '\\'
505#else
506#define SRV_PATH_SEPARATOR '/'
507#endif
508
509/*********************************************************************/
511UNIV_INTERN
512void
514/*=======================*/
515 char* /*str __attribute__((unused))*/)
517{
518#ifdef __WIN__
519 for (; *str; str++) {
520
521 if (*str == '/') {
522 *str = '\\';
523 }
524 }
525#endif
526}
527
528#ifndef UNIV_HOTBACKUP
529/*********************************************************************/
533static
534ulint
535srv_calc_low32(
536/*===========*/
537 ulint file_size)
538{
539 return(0xFFFFFFFFUL & (file_size << UNIV_PAGE_SIZE_SHIFT));
540}
541
542/*********************************************************************/
546static
547ulint
548srv_calc_high32(
549/*============*/
550 ulint file_size)
551{
552 return(file_size >> (32 - UNIV_PAGE_SIZE_SHIFT));
553}
554
555/*********************************************************************/
558ulint
559open_or_create_log_file(
560/*====================*/
561 ibool create_new_db,
563 ibool* log_file_created,
565 ibool log_file_has_been_opened,
568 ulint k,
569 ulint i)
570{
571 ibool ret;
572 ulint size;
573 ulint size_high;
574 char name[10000];
575 ulint dirnamelen;
576
577 UT_NOT_USED(create_new_db);
578
579 *log_file_created = FALSE;
580
581 srv_normalize_path_for_win(srv_log_group_home_dirs[k]);
582
583 dirnamelen = strlen(srv_log_group_home_dirs[k]);
584 ut_a(dirnamelen < (sizeof name) - 10 - sizeof "ib_logfile");
585 memcpy(name, srv_log_group_home_dirs[k], dirnamelen);
586
587 /* Add a path separator if needed. */
588 if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
589 name[dirnamelen++] = SRV_PATH_SEPARATOR;
590 }
591
592 sprintf(name + dirnamelen, "%s%lu", "ib_logfile", (ulong) i);
593
594 files[i] = os_file_create(innodb_file_log_key, name,
595 OS_FILE_CREATE, OS_FILE_NORMAL,
596 OS_LOG_FILE, &ret);
597 if (ret == FALSE) {
598 if (os_file_get_last_error(FALSE) != OS_FILE_ALREADY_EXISTS
599#ifdef UNIV_AIX
600 /* AIX 5.1 after security patch ML7 may have errno set
601 to 0 here, which causes our function to return 100;
602 work around that AIX problem */
603 && os_file_get_last_error(FALSE) != 100
604#endif
605 ) {
606 drizzled::errmsg_printf(drizzled::error::ERROR,
607 "InnoDB: Error in creating or opening %s", name);
608
609 return(DB_ERROR);
610 }
611
612 files[i] = os_file_create(innodb_file_log_key, name,
613 OS_FILE_OPEN, OS_FILE_AIO,
614 OS_LOG_FILE, &ret);
615 if (!ret) {
616 drizzled::errmsg_printf(drizzled::error::ERROR,
617 "InnoDB: Error in opening %s.", name);
618
619 return(DB_ERROR);
620 }
621
622 ret = os_file_get_size(files[i], &size, &size_high);
623 ut_a(ret);
624
625 if (size != srv_calc_low32(srv_log_file_size)
626 || size_high != srv_calc_high32(srv_log_file_size)) {
627
628 drizzled::errmsg_printf(drizzled::error::ERROR,
629 "InnoDB: Error: log file %s is of different size %lu %lu bytes than specified in the .cnf"
630 " file %lu %lu bytes!",
631 name, (ulong) size_high, (ulong) size,
632 (ulong) srv_calc_high32(srv_log_file_size),
633 (ulong) srv_calc_low32(srv_log_file_size));
634
635 return(DB_ERROR);
636 }
637 } else {
638 *log_file_created = TRUE;
639
640 drizzled::errmsg_printf(drizzled::error::INFO,
641 "InnoDB: Log file %s did not exist: new to be created",
642 name);
643 if (log_file_has_been_opened) {
644
645 return(DB_ERROR);
646 }
647
648 drizzled::errmsg_printf(drizzled::error::INFO,
649 "InnoDB: Setting log file %s size to %lu MB",
650 name, (ulong) srv_log_file_size
651 >> (20 - UNIV_PAGE_SIZE_SHIFT));
652
653 drizzled::errmsg_printf(drizzled::error::INFO,
654 "InnoDB: Database physically writes the file full: wait...\n");
655
656 ret = os_file_set_size(name, files[i],
657 srv_calc_low32(srv_log_file_size),
658 srv_calc_high32(srv_log_file_size));
659 if (!ret) {
660 drizzled::errmsg_printf(drizzled::error::ERROR,
661 "InnoDB: Error in creating %s: probably out of disk space",
662 name);
663
664 return(DB_ERROR);
665 }
666 }
667
668 ret = os_file_close(files[i]);
669 ut_a(ret);
670
671 if (i == 0) {
672 /* Create in memory the file space object
673 which is for this log group */
674
675 fil_space_create(name,
676 2 * k + SRV_LOG_SPACE_FIRST_ID, 0, FIL_LOG);
677 }
678
680
681 fil_node_create(name, srv_log_file_size,
682 2 * k + SRV_LOG_SPACE_FIRST_ID, FALSE);
683#ifdef UNIV_LOG_ARCHIVE
684 /* If this is the first log group, create the file space object
685 for archived logs.
686 Under MySQL, no archiving ever done. */
687
688 if (k == 0 && i == 0) {
689 arch_space_id = 2 * k + 1 + SRV_LOG_SPACE_FIRST_ID;
690
691 fil_space_create("arch_log_space", arch_space_id, 0, FIL_LOG);
692 } else {
693 arch_space_id = ULINT_UNDEFINED;
694 }
695#endif /* UNIV_LOG_ARCHIVE */
696 if (i == 0) {
697 log_group_init(k, srv_n_log_files,
698 srv_log_file_size * UNIV_PAGE_SIZE,
700 SRV_LOG_SPACE_FIRST_ID + 1); /* dummy arch
701 space id */
702 }
703
704 return(DB_SUCCESS);
705}
706
707/*********************************************************************/
710ulint
711open_or_create_data_files(
712/*======================*/
713 ibool* create_new_db,
715#ifdef UNIV_LOG_ARCHIVE
716 ulint* min_arch_log_no,
718 ulint* max_arch_log_no,
720#endif /* UNIV_LOG_ARCHIVE */
721 ib_uint64_t* min_flushed_lsn,
723 ib_uint64_t* max_flushed_lsn,
725 ulint* sum_of_new_sizes)
727{
728 ibool ret;
729 ulint i;
730 ibool one_opened = FALSE;
731 ibool one_created = FALSE;
732 ulint size;
733 ulint size_high;
734 ulint rounded_size_pages;
735 char name[10000];
736
737 if (srv_n_data_files >= 1000) {
738 drizzled::errmsg_printf(drizzled::error::ERROR,
739 "InnoDB: can only have < 1000 data files you have defined %lu",
740 (ulong) srv_n_data_files);
741 return(DB_ERROR);
742 }
743
744 *sum_of_new_sizes = 0;
745
746 *create_new_db = FALSE;
747
748 srv_normalize_path_for_win(srv_data_home);
749
750 for (i = 0; i < srv_n_data_files; i++) {
751 ulint dirnamelen;
752
753 srv_normalize_path_for_win(srv_data_file_names[i]);
754 dirnamelen = strlen(srv_data_home);
755
756 ut_a(dirnamelen + strlen(srv_data_file_names[i])
757 < (sizeof name) - 1);
758 memcpy(name, srv_data_home, dirnamelen);
759 /* Add a path separator if needed. */
760 if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
761 name[dirnamelen++] = SRV_PATH_SEPARATOR;
762 }
763
764 strcpy(name + dirnamelen, srv_data_file_names[i]);
765
766 if (srv_data_file_is_raw_partition[i] == 0) {
767
768 /* First we try to create the file: if it already
769 exists, ret will get value FALSE */
770
771 files[i] = os_file_create(innodb_file_data_key,
772 name, OS_FILE_CREATE,
773 OS_FILE_NORMAL,
774 OS_DATA_FILE, &ret);
775
776 if (ret == FALSE && os_file_get_last_error(FALSE)
777 != OS_FILE_ALREADY_EXISTS
778#ifdef UNIV_AIX
779 /* AIX 5.1 after security patch ML7 may have
780 errno set to 0 here, which causes our function
781 to return 100; work around that AIX problem */
782 && os_file_get_last_error(FALSE) != 100
783#endif
784 ) {
785 drizzled::errmsg_printf(drizzled::error::ERROR,
786 "InnoDB: Error in creating or opening %s",
787 name);
788
789 return(DB_ERROR);
790 }
791 } else if (srv_data_file_is_raw_partition[i] == SRV_NEW_RAW) {
792 /* The partition is opened, not created; then it is
793 written over */
794
796 srv_created_new_raw = TRUE;
797
798 files[i] = os_file_create(innodb_file_data_key,
799 name, OS_FILE_OPEN_RAW,
800 OS_FILE_NORMAL,
801 OS_DATA_FILE, &ret);
802 if (!ret) {
803 drizzled::errmsg_printf(drizzled::error::ERROR,
804 "InnoDB: Error in opening %s", name);
805
806 return(DB_ERROR);
807 }
808 } else if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
810
811 ret = FALSE;
812 } else {
813 ut_a(0);
814 }
815
816 if (ret == FALSE) {
817 /* We open the data file */
818
819 if (one_created) {
820 drizzled::errmsg_printf(drizzled::error::ERROR,
821 "InnoDB: Error: data files can only be added at the end of a tablespace, but"
822 " data file %s existed beforehand.",
823 name);
824 return(DB_ERROR);
825 }
826
827 if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
828 files[i] = os_file_create(
829 innodb_file_data_key,
830 name, OS_FILE_OPEN_RAW,
831 OS_FILE_NORMAL, OS_DATA_FILE, &ret);
832 } else if (i == 0) {
833 files[i] = os_file_create(
834 innodb_file_data_key,
835 name, OS_FILE_OPEN_RETRY,
836 OS_FILE_NORMAL, OS_DATA_FILE, &ret);
837 } else {
838 files[i] = os_file_create(
839 innodb_file_data_key,
840 name, OS_FILE_OPEN, OS_FILE_NORMAL,
841 OS_DATA_FILE, &ret);
842 }
843
844 if (!ret) {
845 drizzled::errmsg_printf(drizzled::error::ERROR,
846 "InnoDB: Error in opening %s", name);
848
849 return(DB_ERROR);
850 }
851
852 if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
853
854 goto skip_size_check;
855 }
856
857 ret = os_file_get_size(files[i], &size, &size_high);
858 ut_a(ret);
859 /* Round size downward to megabytes */
860
861 rounded_size_pages
862 = (size / (1024 * 1024) + 4096 * size_high)
863 << (20 - UNIV_PAGE_SIZE_SHIFT);
864
865 if (i == srv_n_data_files - 1
866 && srv_auto_extend_last_data_file) {
867
868 if (srv_data_file_sizes[i] > rounded_size_pages
869 || (srv_last_file_size_max > 0
870 && srv_last_file_size_max
871 < rounded_size_pages)) {
872
873 drizzled::errmsg_printf(drizzled::error::ERROR,
874 "InnoDB: Error: auto-extending data file %s is of a different size. "
875 "%lu pages (rounded down to MB) than specified in the .cnf file: "
876 "initial %lu pages, max %lu (relevant if non-zero) pages!",
877 name,
878 (ulong) rounded_size_pages,
879 (ulong) srv_data_file_sizes[i],
880 (ulong)
881 srv_last_file_size_max);
882
883 return(DB_ERROR);
884 }
885
886 srv_data_file_sizes[i] = rounded_size_pages;
887 }
888
889 if (rounded_size_pages != srv_data_file_sizes[i]) {
890
891 drizzled::errmsg_printf(drizzled::error::ERROR,
892 "InnoDB: Error: data file %s is of a different size. "
893 "%lu pages (rounded down to MB). "
894 "Than specified in the .cnf file %lu pages!",
895 name,
896 (ulong) rounded_size_pages,
897 (ulong) srv_data_file_sizes[i]);
898
899 return(DB_ERROR);
900 }
901skip_size_check:
902 fil_read_flushed_lsn_and_arch_log_no(
903 files[i], one_opened,
904#ifdef UNIV_LOG_ARCHIVE
905 min_arch_log_no, max_arch_log_no,
906#endif /* UNIV_LOG_ARCHIVE */
907 min_flushed_lsn, max_flushed_lsn);
908 one_opened = TRUE;
909 } else {
910 /* We created the data file and now write it full of
911 zeros */
912
913 one_created = TRUE;
914
915 if (i > 0) {
916 drizzled::errmsg_printf(drizzled::error::INFO,
917 " InnoDB: Data file %s did not exist: new to be created",
918 name);
919 } else {
920 drizzled::errmsg_printf(drizzled::error::INFO,
921 "InnoDB: The first specified data file %s did not exist. A new database to be created!", name);
922 *create_new_db = TRUE;
923 }
924
925 drizzled::errmsg_printf(drizzled::error::INFO,
926 " InnoDB: Setting file %s size to %lu MB",
927 name, (ulong) (srv_data_file_sizes[i]
928 >> (20 - UNIV_PAGE_SIZE_SHIFT)));
929
930 drizzled::errmsg_printf(drizzled::error::INFO,
931 "InnoDB: Database physically writes the file full: wait...");
932
933 ret = os_file_set_size(
934 name, files[i],
935 srv_calc_low32(srv_data_file_sizes[i]),
936 srv_calc_high32(srv_data_file_sizes[i]));
937
938 if (!ret) {
939 drizzled::errmsg_printf(drizzled::error::ERROR,
940 "InnoDB: Error in creating %s: probably out of disk space", name);
941
942 return(DB_ERROR);
943 }
944
945 *sum_of_new_sizes = *sum_of_new_sizes
946 + srv_data_file_sizes[i];
947 }
948
949 ret = os_file_close(files[i]);
950 ut_a(ret);
951
952 if (i == 0) {
953 fil_space_create(name, 0, 0, FIL_TABLESPACE);
954 }
955
957
958 fil_node_create(name, srv_data_file_sizes[i], 0,
959 srv_data_file_is_raw_partition[i] != 0);
960 }
961
962 return(DB_SUCCESS);
963}
964
965/********************************************************************
966Starts InnoDB and creates a new database if database files
967are not found and the user wants.
968@return DB_SUCCESS or error code */
969UNIV_INTERN
970int
972/*====================================*/
973{
974 ibool create_new_db;
975 ibool log_file_created;
976 ibool log_created = FALSE;
977 ibool log_opened = FALSE;
978 ib_uint64_t min_flushed_lsn;
979 ib_uint64_t max_flushed_lsn;
980#ifdef UNIV_LOG_ARCHIVE
981 ulint min_arch_log_no;
982 ulint max_arch_log_no;
983#endif /* UNIV_LOG_ARCHIVE */
984 ulint sum_of_new_sizes;
985 ulint sum_of_data_file_sizes;
986 ulint tablespace_size_in_header;
987 ulint err;
988 ulint i;
989 ulint io_limit;
990 my_bool srv_file_per_table_original_value
992 mtr_t mtr;
993#ifdef HAVE_DARWIN_THREADS
994# ifdef F_FULLFSYNC
995 /* This executable has been compiled on Mac OS X 10.3 or later.
996 Assume that F_FULLFSYNC is available at run-time. */
997 srv_have_fullfsync = TRUE;
998# else /* F_FULLFSYNC */
999 /* This executable has been compiled on Mac OS X 10.2
1000 or earlier. Determine if the executable is running
1001 on Mac OS X 10.3 or later. */
1002 struct utsname utsname;
1003 if (uname(&utsname)) {
1004 fputs(_("InnoDB: cannot determine Mac OS X version!\n"), stderr);
1005 } else {
1006 srv_have_fullfsync = strcmp(utsname.release, "7.") >= 0;
1007 }
1008 if (!srv_have_fullfsync) {
1009 fputs(_("InnoDB: On Mac OS X, fsync() may be"
1010 " broken on internal drives,\n"
1011 "InnoDB: making transactions unsafe!\n"), stderr);
1012 }
1013# endif /* F_FULLFSYNC */
1014#endif /* HAVE_DARWIN_THREADS */
1015
1016 if (sizeof(ulint) != sizeof(void*)) {
1017 drizzled::errmsg_printf(drizzled::error::WARN,
1018 _("InnoDB: Error: size of InnoDB's ulint is %lu, but size of void* is %lu. "
1019 "The sizes should be the same so that on a 64-bit platform you can. Allocate more than 4 GB of memory."),
1020 (ulong)sizeof(ulint), (ulong)sizeof(void*));
1021 }
1022
1023 /* System tables are created in tablespace 0. Thus, we must
1024 temporarily clear srv_file_per_table. This is ok, because the
1025 server will not accept connections (which could modify
1026 innodb_file_per_table) until this function has returned. */
1027 srv_file_per_table = FALSE;
1028#ifdef UNIV_DEBUG
1029 drizzled::errmsg_printf(drizzled::error::INFO,
1030 _("InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n"));
1031#endif
1032
1033#ifdef UNIV_IBUF_DEBUG
1034 drizzled::errmsg_printf(drizzled::error::INFO,
1035 _("InnoDB: !!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!\n"
1036# ifdef UNIV_IBUF_COUNT_DEBUG
1037 "InnoDB: !!!!!!!! UNIV_IBUF_COUNT_DEBUG switched on !!!!!!!!!\n"
1038 "InnoDB: Crash recovery will fail with UNIV_IBUF_COUNT_DEBUG\n"
1039# endif
1040 ));
1041#endif
1042
1043#ifdef UNIV_BLOB_DEBUG
1044 fprintf(stderr,
1045 "InnoDB: !!!!!!!! UNIV_BLOB_DEBUG switched on !!!!!!!!!\n"
1046 "InnoDB: Server restart may fail with UNIV_BLOB_DEBUG\n");
1047#endif /* UNIV_BLOB_DEBUG */
1048
1049#ifdef UNIV_SYNC_DEBUG
1050 drizzled::errmsg_printf(drizzled::error::INFO,
1051 _("InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n"));
1052#endif
1053
1054#ifdef UNIV_SEARCH_DEBUG
1055 drizzled::errmsg_printf(drizzled::error::INFO,
1056 _("InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n"));
1057#endif
1058
1059#ifdef UNIV_LOG_LSN_DEBUG
1060 drizzled::errmsg_printf(drizzled::error::INFO,
1061 _("InnoDB: !!!!!!!! UNIV_LOG_LSN_DEBUG switched on !!!!!!!!!\n"));
1062#endif /* UNIV_LOG_LSN_DEBUG */
1063#ifdef UNIV_MEM_DEBUG
1064 drizzled::errmsg_printf(drizzled::error::INFO,
1065 _("InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n"));
1066#endif
1067
1068 if (UNIV_LIKELY(srv_use_sys_malloc))
1069 {
1070 drizzled::errmsg_printf(drizzled::error::INFO, _("InnoDB: The InnoDB memory heap is disabled\n"));
1071 }
1072
1073 drizzled::errmsg_printf(drizzled::error::INFO, "InnoDB: " IB_ATOMICS_STARTUP_MSG
1074 "\nInnoDB: Compressed tables use zlib " ZLIB_VERSION
1075#ifdef UNIV_ZIP_DEBUG
1076 " with validation"
1077#endif /* UNIV_ZIP_DEBUG */
1078#ifdef UNIV_ZIP_COPY
1079 " and extra copying"
1080#endif /* UNIV_ZIP_COPY */
1081 " ");
1082
1083
1084 /* Since InnoDB does not currently clean up all its internal data
1085 structures in MySQL Embedded Server Library server_end(), we
1086 print an error message if someone tries to start up InnoDB a
1087 second time during the process lifetime. */
1088
1089 if (srv_start_has_been_called) {
1090 drizzled::errmsg_printf(drizzled::error::ERROR,
1091 "InnoDB: Error: startup called second time during the process lifetime.\n");
1092 }
1093
1094 srv_start_has_been_called = TRUE;
1095
1096#ifdef UNIV_DEBUG
1097 log_do_write = TRUE;
1098#endif /* UNIV_DEBUG */
1099 /* yydebug = TRUE; */
1100
1101 srv_is_being_started = TRUE;
1103
1104#ifdef __WIN__
1105 switch (os_get_os_version()) {
1106 case OS_WIN95:
1107 case OS_WIN31:
1108 case OS_WINNT:
1109 /* On Win 95, 98, ME, Win32 subsystem for Windows 3.1,
1110 and NT use simulated aio. In NT Windows provides async i/o,
1111 but when run in conjunction with InnoDB Hot Backup, it seemed
1112 to corrupt the data files. */
1113
1114 srv_use_native_aio = FALSE;
1115 break;
1116
1117 case OS_WIN2000:
1118 case OS_WINXP:
1119 /* On 2000 and XP, async IO is available. */
1120 srv_use_native_aio = TRUE;
1121 break;
1122
1123 default:
1124 /* Vista and later have both async IO and condition variables */
1125 srv_use_native_aio = TRUE;
1126 srv_use_native_conditions = TRUE;
1127 break;
1128 }
1129
1130#elif defined(LINUX_NATIVE_AIO)
1131
1132 if (srv_use_native_aio) {
1133 drizzled::errmsg_printf(drizzled::error::INFO,
1134 _("InnoDB: Using Linux native AIO"));
1135 }
1136#else
1137 /* Currently native AIO is supported only on windows and linux
1138 and that also when the support is compiled in. In all other
1139 cases, we ignore the setting of innodb_use_native_aio. */
1140 srv_use_native_aio = FALSE;
1141
1142#endif
1143
1144 if (srv_file_flush_method_str == NULL) {
1145 /* These are the default options */
1146
1147 srv_unix_file_flush_method = SRV_UNIX_FSYNC;
1148
1149 srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
1150#ifndef __WIN__
1151 } else if (0 == ut_strcmp(srv_file_flush_method_str, "fsync")) {
1152 srv_unix_file_flush_method = SRV_UNIX_FSYNC;
1153
1154 } else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DSYNC")) {
1155 srv_unix_file_flush_method = SRV_UNIX_O_DSYNC;
1156
1157 } else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DIRECT")) {
1158 srv_unix_file_flush_method = SRV_UNIX_O_DIRECT;
1159
1160 } else if (0 == ut_strcmp(srv_file_flush_method_str, "ALL_O_DIRECT")) {
1161 srv_unix_file_flush_method = SRV_UNIX_ALL_O_DIRECT;
1162
1163 } else if (0 == ut_strcmp(srv_file_flush_method_str, "littlesync")) {
1164 srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC;
1165
1166 } else if (0 == ut_strcmp(srv_file_flush_method_str, "nosync")) {
1167 srv_unix_file_flush_method = SRV_UNIX_NOSYNC;
1168#else
1169 } else if (0 == ut_strcmp(srv_file_flush_method_str, "normal")) {
1170 srv_win_file_flush_method = SRV_WIN_IO_NORMAL;
1171 srv_use_native_aio = FALSE;
1172
1173 } else if (0 == ut_strcmp(srv_file_flush_method_str, "unbuffered")) {
1174 srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
1175 srv_use_native_aio = FALSE;
1176
1177 } else if (0 == ut_strcmp(srv_file_flush_method_str,
1178 "async_unbuffered")) {
1179 srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
1180#endif
1181 } else {
1182 drizzled::errmsg_printf(drizzled::error::ERROR,
1183 "InnoDB: Unrecognized value %s for innodb_flush_method",
1184 srv_file_flush_method_str);
1185 return(DB_ERROR);
1186 }
1187
1188 /* Note that the call srv_boot() also changes the values of
1189 some variables to the units used by InnoDB internally */
1190
1191 /* Set the maximum number of threads which can wait for a semaphore
1192 inside InnoDB: this is the 'sync wait array' size, as well as the
1193 maximum number of threads that can wait in the 'srv_conc array' for
1194 their time to enter InnoDB. */
1195
1196 if (srv_buf_pool_size >= 1000 * 1024 * 1024) {
1197 /* If buffer pool is less than 1000 MB,
1198 assume fewer threads. Also use only one
1199 buffer pool instance */
1200 srv_max_n_threads = 50000;
1201
1202 } else if (srv_buf_pool_size >= 8 * 1024 * 1024) {
1203
1205 srv_max_n_threads = 10000;
1206 } else {
1208 srv_max_n_threads = 1000; /* saves several MB of memory,
1209 especially in 64-bit
1210 computers */
1211 }
1212
1213 err = srv_boot();
1214
1215 if (err != DB_SUCCESS) {
1216
1217 return((int) err);
1218 }
1219
1220 mutex_create(srv_monitor_file_mutex_key,
1221 &srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
1222
1223 if (srv_innodb_status) {
1224 srv_monitor_file_name = static_cast<char *>(mem_alloc(
1225 strlen(fil_path_to_mysql_datadir)
1226 + 20 + sizeof "/innodb_status."));
1227 sprintf(srv_monitor_file_name, "%s/innodb_status.%lu",
1228 fil_path_to_mysql_datadir, os_proc_get_number());
1229 srv_monitor_file = fopen(srv_monitor_file_name, "w+");
1230 if (!srv_monitor_file) {
1231 drizzled::errmsg_printf(drizzled::error::ERROR,
1232 "InnoDB: unable to create %s: %s\n", srv_monitor_file_name, strerror(errno));
1233 return(DB_ERROR);
1234 }
1235 } else {
1236 srv_monitor_file_name = NULL;
1237 srv_monitor_file = os_file_create_tmpfile();
1238 if (!srv_monitor_file) {
1239 return(DB_ERROR);
1240 }
1241 }
1242
1243 mutex_create(srv_dict_tmpfile_mutex_key,
1244 &srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1245
1246 srv_dict_tmpfile = os_file_create_tmpfile();
1247 if (!srv_dict_tmpfile) {
1248 return(DB_ERROR);
1249 }
1250
1251 mutex_create(srv_misc_tmpfile_mutex_key,
1252 &srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1253
1254 srv_misc_tmpfile = os_file_create_tmpfile();
1255 if (!srv_misc_tmpfile) {
1256 return(DB_ERROR);
1257 }
1258
1259 /* innodb_file_io_threads used to be user settable.
1260 It is now just a combination of read_io_threads and
1261 write_io_threads that is set by innodb internally. */
1262
1263 /* Now overwrite the value on srv_n_file_io_threads */
1264 srv_n_file_io_threads = 2 + srv_n_read_io_threads
1265 + srv_n_write_io_threads;
1266
1267 ut_a(srv_n_file_io_threads <= SRV_MAX_N_IO_THREADS);
1268
1269 io_limit = 8 * SRV_N_PENDING_IOS_PER_THREAD;
1270
1271 /* On Windows when using native aio the number of aio requests
1272 that a thread can handle at a given time is limited to 32
1273 i.e.: SRV_N_PENDING_IOS_PER_THREAD */
1274# ifdef __WIN__
1275 if (srv_use_native_aio) {
1276 io_limit = SRV_N_PENDING_IOS_PER_THREAD;
1277 }
1278# endif /* __WIN__ */
1279
1280 os_aio_init(io_limit,
1281 srv_n_read_io_threads,
1282 srv_n_write_io_threads,
1283 SRV_MAX_N_PENDING_SYNC_IOS);
1284
1285 fil_init(srv_file_per_table ? 50000 : 5000,
1286 srv_max_n_open_files);
1287
1288 /* Print time to initialize the buffer pool */
1289
1290 if (srv_buf_pool_size >= 1024 * 1024 * 1024) {
1291 drizzled::errmsg_printf(drizzled::error::INFO, "InnoDB: Initializing buffer pool, size = %.1fG",
1292 ((double) srv_buf_pool_size) / (1024 * 1024 * 1024));
1293 } else {
1294 drizzled::errmsg_printf(drizzled::error::INFO, "InnoDB: Initializing buffer pool, size = %.1fM",
1295 ((double) srv_buf_pool_size) / (1024 * 1024));
1296 }
1297
1298 err = buf_pool_init(srv_buf_pool_size, srv_buf_pool_instances);
1299
1300 drizzled::errmsg_printf(drizzled::error::INFO, "InnoDB: Completed initialization of buffer pool");
1301
1302 if (err != DB_SUCCESS) {
1303 drizzled::errmsg_printf(drizzled::error::ERROR, "InnoDB: Fatal error: cannot allocate memory for the buffer pool");
1304
1305 return(DB_ERROR);
1306 }
1307
1308#ifdef UNIV_DEBUG
1309 /* We have observed deadlocks with a 5MB buffer pool but
1310 the actual lower limit could very well be a little higher. */
1311
1312 if (srv_buf_pool_size <= 5 * 1024 * 1024) {
1313
1314 drizzled::errmsg_printf(drizzled::error::WARN, "InnoDB: Warning: Small buffer pool size "
1315 "(%luM), the flst_validate() debug function "
1316 "can cause a deadlock if the buffer pool fills up.\n",
1317 srv_buf_pool_size / 1024 / 1024);
1318 }
1319#endif
1320
1321 fsp_init();
1322 log_init();
1323
1324 lock_sys_create(srv_lock_table_size);
1325
1326 /* Create i/o-handler threads: */
1327
1328 for (i = 0; i < srv_n_file_io_threads; i++) {
1329 n[i] = i;
1330
1331 os_thread_create(io_handler_thread, n + i, thread_ids + i);
1332 }
1333
1334#ifdef UNIV_LOG_ARCHIVE
1335 if (0 != ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) {
1336 drizzled::errmsg_printf(drizzled::error::ERROR,
1337 "InnoDB: Error: you must set the log group home dir in my.cnf the same as log arch dir.");
1338
1339 return(DB_ERROR);
1340 }
1341#endif /* UNIV_LOG_ARCHIVE */
1342
1343 if (sizeof(ulint) == 4
1344 && srv_n_log_files * srv_log_file_size
1345 >= (1UL << (32 - UNIV_PAGE_SIZE_SHIFT))) {
1346 drizzled::errmsg_printf(drizzled::error::ERROR,
1347 "InnoDB: Error: combined size of log files must be < 4 GB on 32-bit systems\n");
1348
1349 return(DB_ERROR);
1350 }
1351
1352 sum_of_new_sizes = 0;
1353
1354 for (i = 0; i < srv_n_data_files; i++) {
1355#ifndef __WIN__
1356 if (sizeof(off_t) < 5 && srv_data_file_sizes[i] >= (1UL << (32 - UNIV_PAGE_SIZE_SHIFT))) {
1357 drizzled::errmsg_printf(drizzled::error::ERROR,
1358 "InnoDB: Error: file size must be < 4 GB with this MySQL binary and operating system combination,"
1359 " in some OS's < 2 GB\n");
1360
1361 return(DB_ERROR);
1362 }
1363#endif
1364 sum_of_new_sizes += srv_data_file_sizes[i];
1365 }
1366
1367 if (sum_of_new_sizes < 10485760 / UNIV_PAGE_SIZE) {
1368 drizzled::errmsg_printf(drizzled::error::ERROR, "InnoDB: Error: tablespace size must be at least 10 MB");
1369
1370 return(DB_ERROR);
1371 }
1372
1373 err = open_or_create_data_files(&create_new_db,
1374#ifdef UNIV_LOG_ARCHIVE
1375 &min_arch_log_no, &max_arch_log_no,
1376#endif /* UNIV_LOG_ARCHIVE */
1377 &min_flushed_lsn, &max_flushed_lsn,
1378 &sum_of_new_sizes);
1379 if (err != DB_SUCCESS) {
1380 drizzled::errmsg_printf(drizzled::error::ERROR,
1381 "InnoDB: Could not open or create data files.\n"
1382 "InnoDB: If you tried to add new data files, and it failed here,\n"
1383 "InnoDB: you should now edit innodb_data_file_path in my.cnf back\n"
1384 "InnoDB: to what it was, and remove the new ibdata files InnoDB created\n"
1385 "InnoDB: in this failed attempt. InnoDB only wrote those files full of\n"
1386 "InnoDB: zeros, but did not yet use them in any way. But be careful: do not\n"
1387 "InnoDB: remove old data files which contain your precious data!\n");
1388
1389 return((int) err);
1390 }
1391
1392#ifdef UNIV_LOG_ARCHIVE
1393 srv_normalize_path_for_win(srv_arch_dir);
1394 srv_arch_dir = srv_add_path_separator_if_needed(srv_arch_dir);
1395#endif /* UNIV_LOG_ARCHIVE */
1396
1397 for (i = 0; i < srv_n_log_files; i++) {
1398 err = open_or_create_log_file(create_new_db, &log_file_created,
1399 log_opened, 0, i);
1400 if (err != DB_SUCCESS) {
1401
1402 return((int) err);
1403 }
1404
1405 if (log_file_created) {
1406 log_created = TRUE;
1407 } else {
1408 log_opened = TRUE;
1409 }
1410 if ((log_opened && create_new_db)
1411 || (log_opened && log_created)) {
1412 drizzled::errmsg_printf(drizzled::error::ERROR,
1413 "InnoDB: Error: all log files must be created at the same time.\n"
1414 "InnoDB: All log files must be created also in database creation.\n"
1415 "InnoDB: If you want bigger or smaller log files, shut down the\n"
1416 "InnoDB: database and make sure there were no errors in shutdown.\n"
1417 "InnoDB: Then delete the existing log files. Edit the .cnf file\n"
1418 "InnoDB: and start the database again.\n");
1419
1420 return(DB_ERROR);
1421 }
1422 }
1423
1424 /* Open all log files and data files in the system tablespace: we
1425 keep them open until database shutdown */
1426
1428
1429 if (log_created && !create_new_db
1430#ifdef UNIV_LOG_ARCHIVE
1431 && !srv_archive_recovery
1432#endif /* UNIV_LOG_ARCHIVE */
1433 ) {
1434 if (max_flushed_lsn != min_flushed_lsn
1435#ifdef UNIV_LOG_ARCHIVE
1436 || max_arch_log_no != min_arch_log_no
1437#endif /* UNIV_LOG_ARCHIVE */
1438 ) {
1439 drizzled::errmsg_printf(drizzled::error::ERROR,
1440 "InnoDB: Cannot initialize created log files because\n"
1441 "InnoDB: data files were not in sync with each other\n"
1442 "InnoDB: or the data files are corrupt.\n");
1443
1444 return(DB_ERROR);
1445 }
1446
1447 if (max_flushed_lsn < (ib_uint64_t) 1000) {
1448 drizzled::errmsg_printf(drizzled::error::ERROR,
1449 "InnoDB: Cannot initialize created log files because\n"
1450 "InnoDB: data files are corrupt, or new data files were\n"
1451 "InnoDB: created when the database was started previous\n"
1452 "InnoDB: time but the database was not shut down\n"
1453 "InnoDB: normally after that.\n");
1454
1455 return(DB_ERROR);
1456 }
1457
1458 mutex_enter(&(log_sys->mutex));
1459
1460#ifdef UNIV_LOG_ARCHIVE
1461 /* Do not + 1 arch_log_no because we do not use log
1462 archiving */
1463 recv_reset_logs(max_flushed_lsn, max_arch_log_no, TRUE);
1464#else
1465 recv_reset_logs(max_flushed_lsn, TRUE);
1466#endif /* UNIV_LOG_ARCHIVE */
1467
1468 mutex_exit(&(log_sys->mutex));
1469 }
1470
1472
1473 if (create_new_db) {
1474 mtr_start(&mtr);
1475
1476 fsp_header_init(0, sum_of_new_sizes, &mtr);
1477
1478 mtr_commit(&mtr);
1479
1480 /* To maintain backward compatibility we create only
1481 the first rollback segment before the double write buffer.
1482 All the remaining rollback segments will be created later,
1483 after the double write buffer has been created. */
1485
1486 dict_create();
1487
1489
1490#ifdef UNIV_LOG_ARCHIVE
1491 } else if (srv_archive_recovery) {
1492 drizzled::errmsg_printf(drizzled::error::INFO,
1493 "InnoDB: Starting archive recovery from a backup...");
1494 err = recv_recovery_from_archive_start(
1495 min_flushed_lsn, srv_archive_recovery_limit_lsn,
1496 min_arch_log_no);
1497 if (err != DB_SUCCESS) {
1498
1499 return(DB_ERROR);
1500 }
1501 /* Since ibuf init is in dict_boot, and ibuf is needed
1502 in any disk i/o, first call dict_boot */
1503
1504 dict_boot();
1505
1507
1509
1510 /* Initialize the fsp free limit global variable in the log
1511 system */
1513
1514 recv_recovery_from_archive_finish();
1515#endif /* UNIV_LOG_ARCHIVE */
1516 } else {
1517
1518 /* Check if we support the max format that is stamped
1519 on the system tablespace.
1520 Note: We are NOT allowed to make any modifications to
1521 the TRX_SYS_PAGE_NO page before recovery because this
1522 page also contains the max_trx_id etc. important system
1523 variables that are required for recovery. We need to
1524 ensure that we return the system to a state where normal
1525 recovery is guaranteed to work. We do this by
1526 invalidating the buffer cache, this will force the
1527 reread of the page and restoration to its last known
1528 consistent state, this is REQUIRED for the recovery
1529 process to work. */
1532
1533 if (err != DB_SUCCESS) {
1534 return(err);
1535 }
1536
1537 /* Invalidate the buffer pool to ensure that we reread
1538 the page that we read above, during recovery.
1539 Note that this is not as heavy weight as it seems. At
1540 this point there will be only ONE page in the buf_LRU
1541 and there must be no page in the buf_flush list. */
1543
1544 /* We always try to do a recovery, even if the database had
1545 been shut down normally: this is the normal startup path */
1546
1547 err = recv_recovery_from_checkpoint_start(LOG_CHECKPOINT,
1548 IB_ULONGLONG_MAX,
1549 min_flushed_lsn,
1550 max_flushed_lsn);
1551 if (err != DB_SUCCESS) {
1552
1553 return(DB_ERROR);
1554 }
1555
1556 /* Since the insert buffer init is in dict_boot, and the
1557 insert buffer is needed in any disk i/o, first we call
1558 dict_boot(). Note that trx_sys_init_at_db_start() only needs
1559 to access space 0, and the insert buffer at this stage already
1560 works for space 0. */
1561
1562 dict_boot();
1564
1565 /* Initialize the fsp free limit global variable in the log
1566 system */
1568
1569 /* recv_recovery_from_checkpoint_finish needs trx lists which
1570 are initialized in trx_sys_init_at_db_start(). */
1571
1573
1574 if (srv_apply_log_only)
1575 goto skip_processes;
1576
1577 if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
1578 /* The following call is necessary for the insert
1579 buffer to work with multiple tablespaces. We must
1580 know the mapping between space id's and .ibd file
1581 names.
1582
1583 In a crash recovery, we check that the info in data
1584 dictionary is consistent with what we already know
1585 about space id's from the call of
1586 fil_load_single_table_tablespaces().
1587
1588 In a normal startup, we create the space objects for
1589 every table in the InnoDB data dictionary that has
1590 an .ibd file.
1591
1592 We also determine the maximum tablespace id used. */
1593
1594 dict_check_tablespaces_and_store_max_id(
1596 }
1597
1600
1601 /* It is possible that file_format tag has never
1602 been set. In this case we initialize it to minimum
1603 value. Important to note that we can do it ONLY after
1604 we have finished the recovery process so that the
1605 image of TRX_SYS_PAGE_NO is not stale. */
1607 }
1608
1609 if (!create_new_db && sum_of_new_sizes > 0) {
1610 /* New data file(s) were added */
1611 mtr_start(&mtr);
1612
1613 fsp_header_inc_size(0, sum_of_new_sizes, &mtr);
1614
1615 mtr_commit(&mtr);
1616
1617 /* Immediately write the log record about increased tablespace
1618 size to disk, so that it is durable even if mysqld would crash
1619 quickly */
1620
1622 }
1623
1624#ifdef UNIV_LOG_ARCHIVE
1625 /* Archiving is always off under MySQL */
1626 if (!srv_log_archive_on) {
1627 ut_a(DB_SUCCESS == log_archive_noarchivelog());
1628 } else {
1629 mutex_enter(&(log_sys->mutex));
1630
1631 start_archive = FALSE;
1632
1633 if (log_sys->archiving_state == LOG_ARCH_OFF) {
1634 start_archive = TRUE;
1635 }
1636
1637 mutex_exit(&(log_sys->mutex));
1638
1639 if (start_archive) {
1640 ut_a(DB_SUCCESS == log_archive_archivelog());
1641 }
1642 }
1643#endif /* UNIV_LOG_ARCHIVE */
1644
1645 /* fprintf(stderr, "Max allowed record size %lu\n",
1646 page_get_free_space_of_empty() / 2); */
1647
1648 if (trx_doublewrite == NULL) {
1649 /* Create the doublewrite buffer to a new tablespace */
1650
1652 }
1653
1654 /* Here the double write buffer has already been created and so
1655 any new rollback segments will be allocated after the double
1656 write buffer. The default segment should already exist.
1657 We create the new segments only if it's a new database or
1658 the database was shutdown cleanly. */
1659
1660 /* Note: When creating the extra rollback segments during an upgrade
1661 we violate the latching order, even if the change buffer is empty.
1662 We make an exception in sync0sync.c and check srv_is_being_started
1663 for that violation. It cannot create a deadlock because we are still
1664 running in single threaded mode essentially. Only the IO threads
1665 should be running at this stage. */
1666
1667 trx_sys_create_rsegs(TRX_SYS_N_RSEGS - 1);
1668
1669 /* Create the thread which watches the timeouts for lock waits */
1671 thread_ids + 2 + SRV_MAX_N_IO_THREADS);
1672
1673 /* Create the thread which warns of long semaphore waits */
1675 thread_ids + 3 + SRV_MAX_N_IO_THREADS);
1676
1677 /* Create the thread which prints InnoDB monitor info */
1679 thread_ids + 4 + SRV_MAX_N_IO_THREADS);
1680
1681 /* Create the thread which automaticaly dumps/restore buffer pool */
1683 thread_ids + 5 + SRV_MAX_N_IO_THREADS);
1684
1685 srv_is_being_started = FALSE;
1686
1688
1689 if (err != DB_SUCCESS) {
1690 return((int)DB_ERROR);
1691 }
1692
1693 /* Create the master thread which does purge and other utility
1694 operations */
1695
1696 os_thread_create(&srv_master_thread, NULL, thread_ids
1697 + (1 + SRV_MAX_N_IO_THREADS));
1698
1699 /* Currently we allow only a single purge thread. */
1700 ut_a(srv_n_purge_threads == 0 || srv_n_purge_threads == 1);
1701
1702 /* If the user has requested a separate purge thread then
1703 start the purge thread. */
1704 if (srv_n_purge_threads == 1) {
1705 os_thread_create(&srv_purge_thread, NULL, NULL);
1706 }
1707
1708 /* Wait for the purge and master thread to startup. */
1709
1711 if (srv_thread_has_reserved_slot(SRV_MASTER) == ULINT_UNDEFINED
1712 || (srv_n_purge_threads == 1
1714 == ULINT_UNDEFINED)) {
1715
1716 ut_print_timestamp(stderr);
1717 fprintf(stderr, " InnoDB: "
1718 "Waiting for the background threads to "
1719 "start\n");
1720 os_thread_sleep(1000000);
1721 } else {
1722 break;
1723 }
1724 }
1725
1726#ifdef UNIV_DEBUG
1727 /* buf_debug_prints = TRUE; */
1728#endif /* UNIV_DEBUG */
1729 sum_of_data_file_sizes = 0;
1730
1731 for (i = 0; i < srv_n_data_files; i++) {
1732 sum_of_data_file_sizes += srv_data_file_sizes[i];
1733 }
1734
1735 tablespace_size_in_header = fsp_header_get_tablespace_size();
1736
1737 if (!srv_auto_extend_last_data_file
1738 && sum_of_data_file_sizes != tablespace_size_in_header) {
1739
1740 drizzled::errmsg_printf(drizzled::error::ERROR,
1741 "InnoDB: Error: tablespace size stored in header is %lu pages, but the sum of data file sizes is %lu pages.",
1742 (ulong) tablespace_size_in_header,
1743 (ulong) sum_of_data_file_sizes);
1744
1745 if (srv_force_recovery == 0
1746 && sum_of_data_file_sizes < tablespace_size_in_header) {
1747 /* This is a fatal error, the tail of a tablespace is
1748 missing */
1749
1750 drizzled::errmsg_printf(drizzled::error::ERROR,
1751 "InnoDB: Cannot start InnoDB. The tail of the system tablespace is "
1752 "missing. Have you edited innodb_data_file_path in my.cnf in an "
1753 "inappropriate way, removing ibdata files from there? "
1754 "You can set innodb_force_recovery=1 in my.cnf to force "
1755 "a startup if you are trying to recover a badly corrupt database.");
1756
1757 return(DB_ERROR);
1758 }
1759 }
1760
1761 if (srv_auto_extend_last_data_file
1762 && sum_of_data_file_sizes < tablespace_size_in_header) {
1763
1764 drizzled::errmsg_printf(drizzled::error::ERROR,
1765 "InnoDB: Error: tablespace size stored in header is %lu pages, but the sum of data file sizes"
1766 " is only %lu pages\n",
1767 (ulong) tablespace_size_in_header,
1768 (ulong) sum_of_data_file_sizes);
1769
1770 if (srv_force_recovery == 0) {
1771
1772 drizzled::errmsg_printf(drizzled::error::ERROR,
1773 "InnoDB: Cannot start InnoDB. The tail of the system tablespace is "
1774 "missing. Have you edited innodb_data_file_path in my.cnf in an "
1775 "inappropriate way, removing ibdata files from there? "
1776 "You can set innodb_force_recovery=1 in my.cnf to force "
1777 "a startup if you are trying to recover a badly corrupt database.\n");
1778
1779 return(DB_ERROR);
1780 }
1781 }
1782
1783 /* Check that os_fast_mutexes work as expected */
1784 os_fast_mutex_init(&srv_os_test_mutex);
1785
1786 if (0 != os_fast_mutex_trylock(&srv_os_test_mutex)) {
1787 drizzled::errmsg_printf(drizzled::error::ERROR,
1788 "InnoDB: Error: pthread_mutex_trylock returns an unexpected value on success! Cannot continue.\n");
1789 exit(1);
1790 }
1791
1792 os_fast_mutex_unlock(&srv_os_test_mutex);
1793
1794 os_fast_mutex_lock(&srv_os_test_mutex);
1795
1796 os_fast_mutex_unlock(&srv_os_test_mutex);
1797
1798 os_fast_mutex_free(&srv_os_test_mutex);
1799
1800 if (srv_print_verbose_log) {
1801 drizzled::errmsg_printf(drizzled::error::INFO,
1802 "InnoDB %s started; log sequence number %" PRIu64 "\n",
1803 INNODB_VERSION_STR, srv_start_lsn);
1804 }
1805
1806 if (srv_force_recovery > 0) {
1807 drizzled::errmsg_printf(drizzled::error::ERROR,
1808 "InnoDB: !!! innodb_force_recovery is set to %lu !!!\n",
1809 (ulong) srv_force_recovery);
1810 }
1811
1813 /* Actually, we did not change the undo log format between
1814 4.0 and 4.1.1, and we would not need to run purge to
1815 completion. Note also that the purge algorithm in 4.1.1
1816 can process the the history list again even after a full
1817 purge, because our algorithm does not cut the end of the
1818 history list in all cases so that it would become empty
1819 after a full purge. That mean that we may purge 4.0 type
1820 undo log even after this phase.
1821
1822 The insert buffer record format changed between 4.0 and
1823 4.1.1. It is essential that the insert buffer is emptied
1824 here! */
1825
1826 drizzled::errmsg_printf(drizzled::error::INFO,
1827 "InnoDB: You are upgrading to an InnoDB version which allows multiple. "
1828 "tablespaces. Wait that purge and insert buffer merge run to completion...");
1829 for (;;) {
1830 os_thread_sleep(1000000);
1831
1832 if (0 == strcmp(srv_main_thread_op_info,
1833 "waiting for server activity")) {
1834
1836
1837 break;
1838 }
1839 }
1840 drizzled::errmsg_printf(drizzled::error::INFO,
1841 "InnoDB: Full purge and insert buffer merge completed.");
1842
1844
1845 drizzled::errmsg_printf(drizzled::error::INFO,
1846 "InnoDB: You have now successfully upgraded"
1847 " to the multiple tablespaces\n"
1848 "InnoDB: format. You should NOT DOWNGRADE"
1849 " to an earlier version of\n"
1850 "InnoDB: InnoDB! But if you absolutely need to"
1851 " downgrade, see\n"
1852 "InnoDB: " REFMAN "multiple-tablespaces.html\n"
1853 "InnoDB: for instructions.\n");
1854 }
1855
1856 if (srv_force_recovery == 0) {
1857 /* In the insert buffer we may have even bigger tablespace
1858 id's, because we may have dropped those tablespaces, but
1859 insert buffer merge has not had time to clean the records from
1860 the ibuf tree. */
1861
1863 }
1864
1865skip_processes:
1866 srv_file_per_table = srv_file_per_table_original_value;
1867
1868 srv_was_started = TRUE;
1869
1870 return((int) DB_SUCCESS);
1871}
1872
1873/****************************************************************/
1876UNIV_INTERN
1877int
1879/*=============================*/
1880{
1881 ulint i;
1882 if (!srv_was_started) {
1884 drizzled::errmsg_printf(drizzled::error::ERROR,
1885 "InnoDB: Warning: shutting down a not properly started or created database!");
1886 }
1887
1888 return(DB_SUCCESS);
1889 }
1890
1891 /* 1. Flush the buffer pool to disk, write the current lsn to
1892 the tablespace header(s), and copy all log data to archive.
1893 The step 1 is the real InnoDB shutdown. The remaining steps 2 - ...
1894 just free data structures after the shutdown. */
1895
1896
1897 if (srv_fast_shutdown == 2) {
1898 drizzled::errmsg_printf(drizzled::error::INFO,
1899 "InnoDB: MySQL has requested a very fast shutdown without flushing "
1900 "the InnoDB buffer pool to data files. At the next mysqld startup "
1901 "InnoDB will do a crash recovery!");
1902 }
1903
1905
1906 if (srv_conc_n_threads != 0) {
1907 drizzled::errmsg_printf(drizzled::error::WARN,
1908 "InnoDB: Warning: query counter shows %ld queries still InnoDB: inside InnoDB at shutdown.",
1909 srv_conc_n_threads);
1910 }
1911
1912 /* 2. Make all threads created by InnoDB to exit */
1913
1915
1916 /* In a 'very fast' shutdown, we do not need to wait for these threads
1917 to die; all which counts is that we flushed the log; a 'very fast'
1918 shutdown is essentially a crash. */
1919
1920 if (srv_fast_shutdown == 2) {
1921 return(DB_SUCCESS);
1922 }
1923
1924 /* All threads end up waiting for certain events. Put those events
1925 to the signaled state. Then the threads will exit themselves in
1926 os_thread_event_wait(). */
1927
1928 for (i = 0; i < 1000; i++) {
1929 /* NOTE: IF YOU CREATE THREADS IN INNODB, YOU MUST EXIT THEM
1930 HERE OR EARLIER */
1931
1932 /* a. Let the lock timeout thread exit */
1933 os_event_set(srv_lock_timeout_thread_event);
1934
1935 /* b. srv error monitor thread exits automatically, no need
1936 to do anything here */
1937
1938 /* c. We wake the master thread so that it exits */
1940
1941 /* d. We wake the purge thread so that it exits */
1943
1944 /* e. Exit the i/o threads */
1945
1947
1949
1950 if (os_thread_count == 0) {
1951 /* All the threads have exited or are just exiting;
1952 NOTE that the threads may not have completed their
1953 exit yet. Should we use pthread_join() to make sure
1954 they have exited? If we did, we would have to
1955 remove the pthread_detach() from
1956 os_thread_exit(). Now we just sleep 0.1
1957 seconds and hope that is enough! */
1958
1960
1961 os_thread_sleep(100000);
1962
1963 break;
1964 }
1965
1967
1968 os_thread_sleep(100000);
1969 }
1970
1971 if (i == 1000) {
1972 drizzled::errmsg_printf(drizzled::error::WARN,
1973 "InnoDB: Warning: %lu threads created by InnoDB had not exited at shutdown!",
1974 (ulong) os_thread_count);
1975 }
1976
1977 if (srv_monitor_file) {
1978 fclose(srv_monitor_file);
1979 srv_monitor_file = 0;
1980 if (srv_monitor_file_name) {
1981 unlink(srv_monitor_file_name);
1982 mem_free(srv_monitor_file_name);
1983 }
1984 }
1985 if (srv_dict_tmpfile) {
1986 fclose(srv_dict_tmpfile);
1987 srv_dict_tmpfile = 0;
1988 }
1989
1990 if (srv_misc_tmpfile) {
1991 fclose(srv_misc_tmpfile);
1992 srv_misc_tmpfile = 0;
1993 }
1994
1995 /* This must be disabled before closing the buffer pool
1996 and closing the data dictionary. */
1998
1999 ibuf_close();
2000 log_shutdown();
2003 trx_sys_close();
2004
2005 mutex_free(&srv_monitor_file_mutex);
2006 mutex_free(&srv_dict_tmpfile_mutex);
2007 mutex_free(&srv_misc_tmpfile_mutex);
2008 dict_close();
2010
2011 /* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
2012 them */
2013 os_aio_free();
2014 sync_close();
2015 srv_free();
2016 fil_close();
2017
2018 /* 4. Free the os_conc_mutex and all os_events and os_mutexes */
2019
2020 os_sync_free();
2021
2022 /* 5. Free all allocated memory */
2023
2025 log_mem_free();
2026 buf_pool_free(srv_buf_pool_instances);
2027 mem_close();
2028
2029 /* ut_free_all_mem() frees all allocated memory not freed yet
2030 in shutdown, and it will also free the ut_list_mutex, so it
2031 should be the last one for all operation */
2033
2034 if (os_thread_count != 0
2035 || os_event_count != 0
2036 || os_mutex_count != 0
2037 || os_fast_mutex_count != 0) {
2038 drizzled::errmsg_printf(drizzled::error::WARN,
2039 "InnoDB: Warning: some resources were not cleaned up in shutdown:\n"
2040 "InnoDB: threads %lu, events %lu, os_mutexes %lu, os_fast_mutexes %lu\n",
2041 (ulong) os_thread_count, (ulong) os_event_count,
2042 (ulong) os_mutex_count, (ulong) os_fast_mutex_count);
2043 }
2044
2045 if (dict_foreign_err_file) {
2046 fclose(dict_foreign_err_file);
2047 }
2048 if (lock_latest_err_file) {
2049 fclose(lock_latest_err_file);
2050 }
2051
2052 if (srv_print_verbose_log) {
2053 drizzled::errmsg_printf(drizzled::error::INFO,
2054 "InnoDB: Shutdown completed log sequence number %" PRIu64,
2056 }
2057
2058 srv_was_started = FALSE;
2059 srv_start_has_been_called = FALSE;
2060
2061 return((int) DB_SUCCESS);
2062}
2063#endif /* !UNIV_HOTBACKUP */
UNIV_INTERN void btr_search_disable(void)
Definition btr0sea.cc:206
UNIV_INTERN void btr_search_sys_free(void)
Definition btr0sea.cc:190
UNIV_INTERN void buf_pool_invalidate(void)
Definition buf0buf.cc:4251
UNIV_INTERN void dict_boot(void)
Definition dict0boot.cc:247
UNIV_INTERN void dict_create(void)
Definition dict0boot.cc:473
UNIV_INTERN ulint dict_create_or_check_foreign_constraint_tables(void)
UNIV_INTERN void dict_close(void)
#define FIL_TABLESPACE
Definition fil0fil.h:149
UNIV_INTERN void fil_open_log_and_system_tablespace_files(void)
Definition fil0fil.cc:1605
#define FIL_LOG
Definition fil0fil.h:150
UNIV_INTERN ibool fil_validate(void)
Definition fil0fil.cc:4801
UNIV_INTERN void fil_close(void)
Definition fil0fil.cc:4927
UNIV_INTERN void fsp_init(void)
Definition fsp0fsp.cc:874
UNIV_INTERN ulint fsp_header_get_free_limit(void)
Definition fsp0fsp.cc:1062
UNIV_INTERN ulint fsp_header_get_tablespace_size(void)
Definition fsp0fsp.cc:1094
UNIV_INTERN ibool ibuf_is_empty(void)
UNIV_INTERN void ibuf_close(void)
Definition ibuf0ibuf.cc:454
UNIV_INTERN void ibuf_update_max_tablespace_id(void)
UNIV_INTERN void lock_sys_create(ulint n_cells)
Definition lock0lock.cc:565
UNIV_INTERN void lock_sys_close(void)
Definition lock0lock.cc:583
#define log_do_write
Definition log0log.h:57
UNIV_INTERN void logs_empty_and_mark_files_at_shutdown(void)
Definition log0log.cc:3118
UNIV_INTERN ulint log_archive_archivelog(void)
UNIV_INTERN void log_buffer_flush_to_disk(void)
Definition log0log.cc:1601
UNIV_INTERN void log_group_init(ulint id, ulint n_files, ulint file_size, ulint space_id, ulint archive_space_id)
Definition log0log.cc:925
UNIV_INTERN ulint log_archive_noarchivelog(void)
UNIV_INTERN void log_init(void)
Definition log0log.cc:801
UNIV_INTERN void recv_recovery_rollback_active(void)
Definition log0recv.cc:3299
UNIV_INTERN void recv_reset_logs(ib_uint64_t lsn, ibool new_logs_created)
Definition log0recv.cc:3330
ibool recv_needed_recovery
Definition log0recv.cc:85
#define recv_recovery_from_checkpoint_start(type, lim, min, max)
Definition log0recv.h:171
UNIV_INTERN void recv_recovery_from_checkpoint_finish(void)
Definition log0recv.cc:3255
#define mem_free(PTR)
Definition mem0mem.h:243
UNIV_INTERN void mem_close(void)
Definition mem0dbg.cc:186
UNIV_INTERN void mtr_commit(mtr_t *mtr) __attribute__((nonnull))
Definition mtr0mtr.cc:247
UNIV_INLINE void mtr_start(mtr_t *mtr) __attribute__((nonnull))
#define OS_DATA_FILE
Definition os0file.h:124
#define OS_WIN31
Definition os0file.h:175
UNIV_INTERN ulint os_file_get_last_error(ibool report_all_errors)
Definition os0file.cc:385
#define OS_WINNT
Definition os0file.h:177
#define OS_WIN2000
Definition os0file.h:178
FILE * os_file_create_tmpfile(void)
Definition os0file.cc:729
int os_file_t
Definition os0file.h:87
#define OS_WIN95
Definition os0file.h:176
UNIV_INTERN void os_aio_wake_all_threads_at_shutdown(void)
Definition os0file.cc:3524
UNIV_INTERN ibool os_file_get_size(os_file_t file, ulint *size, ulint *size_high)
Definition os0file.cc:1882
UNIV_INTERN ibool os_file_set_size(const char *name, os_file_t file, ulint size, ulint size_high)
Definition os0file.cc:1953
#define OS_FILE_OPEN
Definition os0file.h:107
#define OS_WINXP
Definition os0file.h:179
UNIV_INTERN ulint os_proc_get_number(void)
Definition os0proc.cc:57
os_mutex_t os_sync_mutex
Definition os0sync.cc:59
UNIV_INTERN void os_mutex_enter(os_mutex_t mutex)
Definition os0sync.cc:809
UNIV_INTERN void os_fast_mutex_free(os_fast_mutex_t *fast_mutex)
Definition os0sync.cc:930
UNIV_INLINE ulint os_fast_mutex_trylock(os_fast_mutex_t *fast_mutex)
UNIV_INTERN void os_fast_mutex_lock(os_fast_mutex_t *fast_mutex)
Definition os0sync.cc:900
UNIV_INTERN void os_sync_free(void)
Definition os0sync.cc:325
UNIV_INTERN void os_event_set(os_event_t event)
Definition os0sync.cc:434
UNIV_INTERN void os_fast_mutex_init(os_fast_mutex_t *fast_mutex)
Definition os0sync.cc:871
UNIV_INTERN void os_mutex_exit(os_mutex_t mutex)
Definition os0sync.cc:824
UNIV_INTERN void os_fast_mutex_unlock(os_fast_mutex_t *fast_mutex)
Definition os0sync.cc:915
ulint os_thread_count
Definition os0sync.cc:67
pthread_mutex_t os_fast_mutex_t
Definition os0sync.h:50
os_thread_t os_thread_id_t
Definition os0thread.h:53
UNIV_INTERN os_thread_t os_thread_create(os_posix_f_t start_f, void *arg, os_thread_id_t *thread_id)
Definition os0thread.cc:110
UNIV_INTERN void os_thread_sleep(ulint tm)
Definition os0thread.cc:265
UNIV_INTERN os_thread_id_t os_thread_get_curr_id(void)
Definition os0thread.cc:93
UNIV_INTERN ulint os_thread_pf(os_thread_id_t a)
Definition os0thread.cc:72
UNIV_INTERN void pars_lexer_close(void)
Definition pars0lex.l:672
ulint srv_buf_pool_size
Definition srv0srv.cc:253
@ SRV_WORKER
Definition srv0srv.h:472
@ SRV_MASTER
Definition srv0srv.h:474
UNIV_INTERN void srv_free(void)
Definition srv0srv.cc:1165
UNIV_INTERN os_thread_ret_t srv_LRU_dump_restore_thread(void *arg)
Definition srv0srv.cc:2540
UNIV_INTERN os_thread_ret_t srv_monitor_thread(void *arg)
Definition srv0srv.cc:2151
@ SRV_FORCE_NO_IBUF_MERGE
Definition srv0srv.h:445
UNIV_INTERN os_thread_ret_t srv_master_thread(void *arg)
Definition srv0srv.cc:2744
UNIV_INTERN os_thread_ret_t srv_error_monitor_thread(void *arg)
Definition srv0srv.cc:2424
@ SRV_UNIX_ALL_O_DIRECT
Definition srv0srv.h:423
@ SRV_UNIX_O_DSYNC
Definition srv0srv.h:416
@ SRV_UNIX_FSYNC
Definition srv0srv.h:415
@ SRV_UNIX_NOSYNC
Definition srv0srv.h:420
@ SRV_UNIX_LITTLESYNC
Definition srv0srv.h:417
@ SRV_UNIX_O_DIRECT
Definition srv0srv.h:421
ulint srv_buf_pool_instances
Definition srv0srv.cc:255
@ SRV_WIN_IO_UNBUFFERED
Definition srv0srv.h:429
@ SRV_WIN_IO_NORMAL
Definition srv0srv.h:428
UNIV_INTERN os_thread_ret_t srv_lock_timeout_thread(void *arg)
Definition srv0srv.cc:2316
my_bool srv_file_per_table
Definition srv0srv.cc:125
UNIV_INTERN os_thread_ret_t srv_purge_thread(void *)
Definition srv0srv.cc:3462
UNIV_INTERN ulint srv_thread_has_reserved_slot(enum srv_thread_type type)
Definition srv0srv.cc:1052
UNIV_INTERN ulint srv_boot(void)
Definition srv0srv.cc:1511
ulint srv_max_file_format_at_startup
Definition srv0srv.cc:131
UNIV_INTERN void srv_wake_master_thread(void)
Definition srv0srv.cc:2660
UNIV_INTERN void srv_wake_purge_thread(void)
Definition srv0srv.cc:2676
@ SRV_NEW_RAW
Definition srv0srv.h:407
@ SRV_OLD_RAW
Definition srv0srv.h:409
UNIV_INTERN void srv_free_paths_and_sizes(void)
Definition srv0start.cc:450
UNIV_INTERN void srv_normalize_path_for_win(char *str)
Definition srv0start.cc:513
#define SRV_LOG_SPACE_FIRST_ID
Definition srv0start.h:129
UNIV_INTERN int innobase_shutdown_for_mysql(void)
ib_uint64_t srv_shutdown_lsn
Definition srv0start.cc:101
srv_shutdown_state
Definition srv0start.h:113
@ SRV_SHUTDOWN_NONE
Definition srv0start.h:114
@ SRV_SHUTDOWN_EXIT_THREADS
Definition srv0start.h:120
ibool srv_was_started
Definition srv0start.cc:118
UNIV_INTERN ibool srv_parse_data_file_paths_and_sizes(char *str)
Definition srv0start.cc:195
ibool srv_is_being_started
Definition srv0start.cc:116
ibool srv_start_raw_disk_in_use
Definition srv0start.cc:110
UNIV_INTERN char * srv_add_path_separator_if_needed(char *str)
ib_uint64_t srv_start_lsn
Definition srv0start.cc:99
UNIV_INTERN int innobase_start_or_create_for_mysql(void)
Definition srv0start.cc:971
UNIV_INTERN ibool srv_parse_log_group_home_dirs(char *str)
Definition srv0start.cc:379
ibool srv_startup_is_before_trx_rollback_phase
Definition srv0start.cc:114
UNIV_INTERN void sync_close(void)
UNIV_INTERN ulint trx_sys_file_format_max_check(ulint max_format_id)
Definition trx0sys.cc:1051
UNIV_INTERN void trx_sys_file_format_close(void)
Definition trx0sys.cc:1207
UNIV_INTERN void trx_sys_mark_upgraded_to_multiple_tablespaces(void)
Definition trx0sys.cc:217
UNIV_INTERN void trx_sys_create_doublewrite_buf(void)
Definition trx0sys.cc:252
UNIV_INTERN void trx_sys_init_at_db_start(void)
Definition trx0sys.cc:849
UNIV_INTERN void trx_sys_create(void)
Definition trx0sys.cc:943
ibool trx_doublewrite_must_reset_space_ids
Definition trx0sys.cc:67
trx_doublewrite_t * trx_doublewrite
Definition trx0sys.cc:63
UNIV_INTERN void trx_sys_close(void)
Definition trx0sys.cc:1452
UNIV_INTERN void trx_sys_file_format_init(void)
Definition trx0sys.cc:1189
UNIV_INTERN void trx_sys_create_rsegs(ulint n_rsegs)
Definition trx0sys.cc:1217
UNIV_INTERN void trx_sys_file_format_tag_init(void)
Definition trx0sys.cc:1132
#define ut_a(EXPR)
Definition ut0dbg.h:105
#define UT_NOT_USED(A)
Definition ut0dbg.h:134
UNIV_INLINE int ut_strcmp(const char *str1, const char *str2)
UNIV_INTERN void ut_free_all_mem(void)
Definition ut0mem.cc:411
UNIV_INTERN void ut_print_timestamp(FILE *file)
Definition ut0ut.cc:239