~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/srv/srv0start.cc

  • Committer: Olaf van der Spek
  • Date: 2011-02-12 18:24:24 UTC
  • mto: (2167.1.2 build) (2172.1.4 build)
  • mto: This revision was merged to the branch mainline in revision 2168.
  • Revision ID: olafvdspek@gmail.com-20110212182424-kgnm9osi7qo97at2
casts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
4
 
Copyright (c) 2008, Google Inc.
 
3
Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
 
4
Copyright (C) 2008, Google Inc.
 
5
Copyright (C) 2009, Percona Inc.
5
6
 
6
7
Portions of this file contain modifications contributed and copyrighted by
7
8
Google, Inc. Those modifications are gratefully acknowledged and are described
9
10
incorporated with their permission, and subject to the conditions contained in
10
11
the file COPYING.Google.
11
12
 
 
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
 
18
COPYING.Percona.
 
19
 
12
20
This program is free software; you can redistribute it and/or modify it under
13
21
the terms of the GNU General Public License as published by the Free Software
14
22
Foundation; version 2 of the License.
18
26
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19
27
 
20
28
You should have received a copy of the GNU General Public License along with
21
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22
 
Place, Suite 330, Boston, MA 02111-1307 USA
 
29
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
30
St, Fifth Floor, Boston, MA 02110-1301 USA
23
31
 
24
32
*****************************************************************************/
25
 
/***********************************************************************
26
 
 
27
 
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
28
 
Copyright (c) 2009, Percona Inc.
29
 
 
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
35
 
COPYING.Percona.
36
 
 
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.
40
 
 
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.
45
 
 
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
49
 
 
50
 
***********************************************************************/
51
33
 
52
34
/********************************************************************//**
53
35
@file srv/srv0start.c
103
85
# include "row0row.h"
104
86
# include "row0mysql.h"
105
87
# include "btr0pcur.h"
 
88
# include "thr0loc.h"
 
89
# include "os0sync.h" /* for INNODB_RW_LOCKS_USE_ATOMICS */
 
90
# include "zlib.h" /* for ZLIB_VERSION */
106
91
 
107
92
#include <errno.h>
108
93
#include <unistd.h>
109
94
 
 
95
#include <drizzled/gettext.h> 
 
96
#include <drizzled/errmsg_print.h>
 
97
 
110
98
/** Log sequence number immediately after startup */
111
99
UNIV_INTERN ib_uint64_t srv_start_lsn;
112
100
/** Log sequence number at shutdown */
138
126
/** Files comprising the system tablespace */
139
127
static os_file_t        files[1000];
140
128
 
141
 
/** Mutex protecting the ios count */
142
 
static mutex_t          ios_mutex;
143
 
/** Count of I/O operations in io_handler_thread() */
144
 
static ulint            ios;
145
 
 
146
129
/** io_handler_thread parameters for thread identification */
147
 
static ulint            n[SRV_MAX_N_IO_THREADS + 5];
 
130
static ulint            n[SRV_MAX_N_IO_THREADS + 6];
148
131
/** io_handler_thread identifiers */
149
 
static os_thread_id_t   thread_ids[SRV_MAX_N_IO_THREADS + 5];
 
132
static os_thread_id_t   thread_ids[SRV_MAX_N_IO_THREADS + 6];
150
133
 
151
134
/** We use this mutex to test the return value of pthread_mutex_trylock
152
135
   on successful locking. HP-UX does NOT return 0, though Linux et al do. */
160
143
#define SRV_N_PENDING_IOS_PER_THREAD    OS_AIO_N_PENDING_IOS_PER_THREAD
161
144
#define SRV_MAX_N_PENDING_SYNC_IOS      100
162
145
 
 
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 */
163
154
 
164
155
/*********************************************************************//**
165
156
Convert a numeric string that optionally ends in G or M, to a number
291
282
                return(FALSE);
292
283
        }
293
284
 
294
 
        srv_data_file_names = malloc(i * sizeof *srv_data_file_names);
295
 
        srv_data_file_sizes = malloc(i * sizeof *srv_data_file_sizes);
296
 
        srv_data_file_is_raw_partition = malloc(
297
 
                i * sizeof *srv_data_file_is_raw_partition);
 
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));
298
289
 
299
290
        srv_n_data_files = i;
300
291
 
424
415
                return(FALSE);
425
416
        }
426
417
 
427
 
        srv_log_group_home_dirs = malloc(i * sizeof *srv_log_group_home_dirs);
 
418
        srv_log_group_home_dirs = static_cast<char **>(malloc(i * sizeof *srv_log_group_home_dirs));
428
419
 
429
420
        /* Then store the actual values to our array */
430
421
 
473
464
/********************************************************************//**
474
465
I/o-handler thread function.
475
466
@return OS_THREAD_DUMMY_RETURN */
476
 
static
 
467
extern "C"
 
468
os_thread_ret_t
 
469
io_handler_thread(void* arg);
 
470
 
 
471
extern "C"
477
472
os_thread_ret_t
478
473
io_handler_thread(
479
474
/*==============*/
481
476
                        the aio array */
482
477
{
483
478
        ulint   segment;
484
 
        ulint   i;
485
479
 
486
480
        segment = *((ulint*)arg);
487
481
 
489
483
        fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,
490
484
                os_thread_pf(os_thread_get_curr_id()));
491
485
#endif
492
 
        for (i = 0;; i++) {
 
486
 
 
487
#ifdef UNIV_PFS_THREAD
 
488
        pfs_register_thread(io_handler_thread_key);
 
489
#endif /* UNIV_PFS_THREAD */
 
490
 
 
491
        while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) {
493
492
                fil_aio_wait(segment);
494
 
 
495
 
                mutex_enter(&ios_mutex);
496
 
                ios++;
497
 
                mutex_exit(&ios_mutex);
498
493
        }
499
494
 
500
495
        /* We count the number of threads in os_thread_exit(). A created
501
496
        thread should always use that to exit and not use return() to exit.
502
497
        The thread actually never comes here because it is exited in an
503
498
        os_event_wait(). */
504
 
#if (!defined(__SUNPRO_C) && !defined(__SUNPRO_CC))
505
499
        return 0;
506
 
#endif
507
500
}
508
501
#endif /* !UNIV_HOTBACKUP */
509
502
 
519
512
void
520
513
srv_normalize_path_for_win(
521
514
/*=======================*/
522
 
        char*   str __attribute__((unused)))    /*!< in/out: null-terminated
 
515
        char*   /*str __attribute__((unused))*/)        /*!< in/out: null-terminated
523
516
                                                character string */
524
517
{
525
518
#ifdef __WIN__
532
525
#endif
533
526
}
534
527
 
535
 
/*********************************************************************//**
536
 
Adds a slash or a backslash to the end of a string if it is missing
537
 
and the string is not empty.
538
 
@return string which has the separator if the string is not empty */
539
 
UNIV_INTERN
540
 
char*
541
 
srv_add_path_separator_if_needed(
542
 
/*=============================*/
543
 
        char*   str)    /*!< in: null-terminated character string */
544
 
{
545
 
        char*   out_str;
546
 
        ulint   len     = ut_strlen(str);
547
 
 
548
 
        if (len == 0 || str[len - 1] == SRV_PATH_SEPARATOR) {
549
 
 
550
 
                return(str);
551
 
        }
552
 
 
553
 
        out_str = ut_malloc(len + 2);
554
 
        memcpy(out_str, str, len);
555
 
        out_str[len] = SRV_PATH_SEPARATOR;
556
 
        out_str[len + 1] = 0;
557
 
 
558
 
        return(out_str);
559
 
}
560
 
 
561
528
#ifndef UNIV_HOTBACKUP
562
529
/*********************************************************************//**
563
530
Calculates the low 32 bits when a file size which is given as a number
606
573
        ulint   size;
607
574
        ulint   size_high;
608
575
        char    name[10000];
 
576
        ulint   dirnamelen;
609
577
 
610
578
        UT_NOT_USED(create_new_db);
611
579
 
612
580
        *log_file_created = FALSE;
613
581
 
614
582
        srv_normalize_path_for_win(srv_log_group_home_dirs[k]);
615
 
        srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed(
616
 
                srv_log_group_home_dirs[k]);
617
 
 
618
 
        ut_a(strlen(srv_log_group_home_dirs[k])
619
 
             < (sizeof name) - 10 - sizeof "ib_logfile");
620
 
        sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k],
621
 
                "ib_logfile", (ulong) i);
622
 
 
623
 
        files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL,
 
583
 
 
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);
 
587
 
 
588
        /* Add a path separator if needed. */
 
589
        if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
 
590
                name[dirnamelen++] = SRV_PATH_SEPARATOR;
 
591
        }
 
592
 
 
593
        sprintf(name + dirnamelen, "%s%lu", "ib_logfile", (ulong) i);
 
594
 
 
595
        files[i] = os_file_create(innodb_file_log_key, name,
 
596
                                  OS_FILE_CREATE, OS_FILE_NORMAL,
624
597
                                  OS_LOG_FILE, &ret);
625
598
        if (ret == FALSE) {
626
599
                if (os_file_get_last_error(FALSE) != OS_FILE_ALREADY_EXISTS
631
604
                    && os_file_get_last_error(FALSE) != 100
632
605
#endif
633
606
                    ) {
634
 
                        fprintf(stderr,
635
 
                                "InnoDB: Error in creating"
636
 
                                " or opening %s\n", name);
 
607
                  drizzled::errmsg_printf(drizzled::error::ERROR,
 
608
                                          "InnoDB: Error in creating or opening %s", name);
637
609
 
638
 
                        return(DB_ERROR);
 
610
                  return(DB_ERROR);
639
611
                }
640
612
 
641
 
                files[i] = os_file_create(name, OS_FILE_OPEN, OS_FILE_AIO,
 
613
                files[i] = os_file_create(innodb_file_log_key, name,
 
614
                                          OS_FILE_OPEN, OS_FILE_AIO,
642
615
                                          OS_LOG_FILE, &ret);
643
616
                if (!ret) {
644
 
                        fprintf(stderr,
645
 
                                "InnoDB: Error in opening %s\n", name);
 
617
                  drizzled::errmsg_printf(drizzled::error::ERROR,
 
618
                                          "InnoDB: Error in opening %s.", name);
646
619
 
647
620
                        return(DB_ERROR);
648
621
                }
653
626
                if (size != srv_calc_low32(srv_log_file_size)
654
627
                    || size_high != srv_calc_high32(srv_log_file_size)) {
655
628
 
656
 
                        fprintf(stderr,
657
 
                                "InnoDB: Error: log file %s is"
658
 
                                " of different size %lu %lu bytes\n"
659
 
                                "InnoDB: than specified in the .cnf"
660
 
                                " file %lu %lu bytes!\n",
661
 
                                name, (ulong) size_high, (ulong) size,
662
 
                                (ulong) srv_calc_high32(srv_log_file_size),
663
 
                                (ulong) srv_calc_low32(srv_log_file_size));
 
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));
664
635
 
665
636
                        return(DB_ERROR);
666
637
                }
667
638
        } else {
668
639
                *log_file_created = TRUE;
669
640
 
670
 
                ut_print_timestamp(stderr);
671
 
 
672
 
                fprintf(stderr,
673
 
                        "  InnoDB: Log file %s did not exist:"
674
 
                        " new to be created\n",
675
 
                        name);
 
641
                drizzled::errmsg_printf(drizzled::error::INFO,
 
642
                                        "InnoDB: Log file %s did not exist: new to be created",
 
643
                                        name);
676
644
                if (log_file_has_been_opened) {
677
645
 
678
646
                        return(DB_ERROR);
679
647
                }
680
648
 
681
 
                fprintf(stderr, "InnoDB: Setting log file %s size to %lu MB\n",
682
 
                        name, (ulong) srv_log_file_size
683
 
                        >> (20 - UNIV_PAGE_SIZE_SHIFT));
 
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));
684
653
 
685
 
                fprintf(stderr,
686
 
                        "InnoDB: Database physically writes the file"
687
 
                        " full: wait...\n");
 
654
                drizzled::errmsg_printf(drizzled::error::INFO,
 
655
                                        "InnoDB: Database physically writes the file full: wait...\n");
688
656
 
689
657
                ret = os_file_set_size(name, files[i],
690
658
                                       srv_calc_low32(srv_log_file_size),
691
659
                                       srv_calc_high32(srv_log_file_size));
692
660
                if (!ret) {
693
 
                        fprintf(stderr,
694
 
                                "InnoDB: Error in creating %s:"
695
 
                                " probably out of disk space\n",
696
 
                                name);
 
661
                  drizzled::errmsg_printf(drizzled::error::ERROR,
 
662
                                          "InnoDB: Error in creating %s: probably out of disk space",
 
663
                                          name);
697
664
 
698
665
                        return(DB_ERROR);
699
666
                }
770
737
        char    name[10000];
771
738
 
772
739
        if (srv_n_data_files >= 1000) {
773
 
                fprintf(stderr, "InnoDB: can only have < 1000 data files\n"
774
 
                        "InnoDB: you have defined %lu\n",
775
 
                        (ulong) srv_n_data_files);
 
740
          drizzled::errmsg_printf(drizzled::error::ERROR,
 
741
                                  "InnoDB: can only have < 1000 data files you have defined %lu",
 
742
                                  (ulong) srv_n_data_files);
776
743
                return(DB_ERROR);
777
744
        }
778
745
 
781
748
        *create_new_db = FALSE;
782
749
 
783
750
        srv_normalize_path_for_win(srv_data_home);
784
 
        srv_data_home = srv_add_path_separator_if_needed(srv_data_home);
785
751
 
786
752
        for (i = 0; i < srv_n_data_files; i++) {
 
753
                ulint   dirnamelen;
 
754
 
787
755
                srv_normalize_path_for_win(srv_data_file_names[i]);
 
756
                dirnamelen = strlen(srv_data_home);
788
757
 
789
 
                ut_a(strlen(srv_data_home) + strlen(srv_data_file_names[i])
 
758
                ut_a(dirnamelen + strlen(srv_data_file_names[i])
790
759
                     < (sizeof name) - 1);
791
 
                sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]);
 
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;
 
764
                }
 
765
 
 
766
                strcpy(name + dirnamelen, srv_data_file_names[i]);
792
767
 
793
768
                if (srv_data_file_is_raw_partition[i] == 0) {
794
769
 
795
770
                        /* First we try to create the file: if it already
796
771
                        exists, ret will get value FALSE */
797
772
 
798
 
                        files[i] = os_file_create(name, OS_FILE_CREATE,
 
773
                        files[i] = os_file_create(innodb_file_data_key,
 
774
                                                  name, OS_FILE_CREATE,
799
775
                                                  OS_FILE_NORMAL,
800
776
                                                  OS_DATA_FILE, &ret);
801
777
 
808
784
                            && os_file_get_last_error(FALSE) != 100
809
785
#endif
810
786
                            ) {
811
 
                                fprintf(stderr,
812
 
                                        "InnoDB: Error in creating"
813
 
                                        " or opening %s\n",
814
 
                                        name);
 
787
                          drizzled::errmsg_printf(drizzled::error::ERROR,
 
788
                                                  "InnoDB: Error in creating or opening %s",
 
789
                                                  name);
815
790
 
816
791
                                return(DB_ERROR);
817
792
                        }
822
797
                        srv_start_raw_disk_in_use = TRUE;
823
798
                        srv_created_new_raw = TRUE;
824
799
 
825
 
                        files[i] = os_file_create(name, OS_FILE_OPEN_RAW,
 
800
                        files[i] = os_file_create(innodb_file_data_key,
 
801
                                                  name, OS_FILE_OPEN_RAW,
826
802
                                                  OS_FILE_NORMAL,
827
803
                                                  OS_DATA_FILE, &ret);
828
804
                        if (!ret) {
829
 
                                fprintf(stderr,
830
 
                                        "InnoDB: Error in opening %s\n", name);
 
805
                          drizzled::errmsg_printf(drizzled::error::ERROR,
 
806
                                                  "InnoDB: Error in opening %s", name);
831
807
 
832
808
                                return(DB_ERROR);
833
809
                        }
843
819
                        /* We open the data file */
844
820
 
845
821
                        if (one_created) {
846
 
                                fprintf(stderr,
847
 
                                        "InnoDB: Error: data files can only"
848
 
                                        " be added at the end\n");
849
 
                                fprintf(stderr,
850
 
                                        "InnoDB: of a tablespace, but"
851
 
                                        " data file %s existed beforehand.\n",
852
 
                                        name);
 
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.",
 
825
                                        name);
853
826
                                return(DB_ERROR);
854
827
                        }
855
828
 
856
829
                        if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
857
830
                                files[i] = os_file_create(
 
831
                                        innodb_file_data_key,
858
832
                                        name, OS_FILE_OPEN_RAW,
859
833
                                        OS_FILE_NORMAL, OS_DATA_FILE, &ret);
860
834
                        } else if (i == 0) {
861
835
                                files[i] = os_file_create(
 
836
                                        innodb_file_data_key,
862
837
                                        name, OS_FILE_OPEN_RETRY,
863
838
                                        OS_FILE_NORMAL, OS_DATA_FILE, &ret);
864
839
                        } else {
865
840
                                files[i] = os_file_create(
 
841
                                        innodb_file_data_key,
866
842
                                        name, OS_FILE_OPEN, OS_FILE_NORMAL,
867
843
                                        OS_DATA_FILE, &ret);
868
844
                        }
869
845
 
870
846
                        if (!ret) {
871
 
                                fprintf(stderr,
872
 
                                        "InnoDB: Error in opening %s\n", name);
 
847
                          drizzled::errmsg_printf(drizzled::error::ERROR,
 
848
                                                  "InnoDB: Error in opening %s", name);
873
849
                                os_file_get_last_error(TRUE);
874
850
 
875
851
                                return(DB_ERROR);
896
872
                                        && srv_last_file_size_max
897
873
                                        < rounded_size_pages)) {
898
874
 
899
 
                                        fprintf(stderr,
900
 
                                                "InnoDB: Error: auto-extending"
901
 
                                                " data file %s is"
902
 
                                                " of a different size\n"
903
 
                                                "InnoDB: %lu pages (rounded"
904
 
                                                " down to MB) than specified"
905
 
                                                " in the .cnf file:\n"
906
 
                                                "InnoDB: initial %lu pages,"
907
 
                                                " max %lu (relevant if"
908
 
                                                " non-zero) pages!\n",
909
 
                                                name,
910
 
                                                (ulong) rounded_size_pages,
911
 
                                                (ulong) srv_data_file_sizes[i],
912
 
                                                (ulong)
913
 
                                                srv_last_file_size_max);
 
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!",
 
879
                                                          name,
 
880
                                                          (ulong) rounded_size_pages,
 
881
                                                          (ulong) srv_data_file_sizes[i],
 
882
                                                          (ulong)
 
883
                                                          srv_last_file_size_max);
914
884
 
915
885
                                        return(DB_ERROR);
916
886
                                }
920
890
 
921
891
                        if (rounded_size_pages != srv_data_file_sizes[i]) {
922
892
 
923
 
                                fprintf(stderr,
924
 
                                        "InnoDB: Error: data file %s"
925
 
                                        " is of a different size\n"
926
 
                                        "InnoDB: %lu pages"
927
 
                                        " (rounded down to MB)\n"
928
 
                                        "InnoDB: than specified"
929
 
                                        " in the .cnf file %lu pages!\n",
 
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!",
930
897
                                        name,
931
898
                                        (ulong) rounded_size_pages,
932
899
                                        (ulong) srv_data_file_sizes[i]);
948
915
                        one_created = TRUE;
949
916
 
950
917
                        if (i > 0) {
951
 
                                ut_print_timestamp(stderr);
952
 
                                fprintf(stderr,
953
 
                                        "  InnoDB: Data file %s did not"
954
 
                                        " exist: new to be created\n",
 
918
                                drizzled::errmsg_printf(drizzled::error::INFO,
 
919
                                        "  InnoDB: Data file %s did not exist: new to be created",
955
920
                                        name);
956
921
                        } else {
957
 
                                fprintf(stderr,
958
 
                                        "InnoDB: The first specified"
959
 
                                        " data file %s did not exist:\n"
960
 
                                        "InnoDB: a new database"
961
 
                                        " to be created!\n", name);
 
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);
962
924
                                *create_new_db = TRUE;
963
925
                        }
964
926
 
965
 
                        ut_print_timestamp(stderr);
966
 
                        fprintf(stderr,
967
 
                                "  InnoDB: Setting file %s size to %lu MB\n",
968
 
                                name,
969
 
                                (ulong) (srv_data_file_sizes[i]
970
 
                                         >> (20 - UNIV_PAGE_SIZE_SHIFT)));
 
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)));
971
931
 
972
 
                        fprintf(stderr,
973
 
                                "InnoDB: Database physically writes the"
974
 
                                " file full: wait...\n");
 
932
                        drizzled::errmsg_printf(drizzled::error::INFO,
 
933
                                "InnoDB: Database physically writes the file full: wait...");
975
934
 
976
935
                        ret = os_file_set_size(
977
936
                                name, files[i],
979
938
                                srv_calc_high32(srv_data_file_sizes[i]));
980
939
 
981
940
                        if (!ret) {
982
 
                                fprintf(stderr,
983
 
                                        "InnoDB: Error in creating %s:"
984
 
                                        " probably out of disk space\n", name);
 
941
                          drizzled::errmsg_printf(drizzled::error::ERROR,
 
942
                                                  "InnoDB: Error in creating %s: probably out of disk space", name);
985
943
 
986
944
                                return(DB_ERROR);
987
945
                        }
1003
961
                                srv_data_file_is_raw_partition[i] != 0);
1004
962
        }
1005
963
 
1006
 
        ios = 0;
1007
 
 
1008
 
        mutex_create(&ios_mutex, SYNC_NO_ORDER_CHECK);
1009
 
 
1010
964
        return(DB_SUCCESS);
1011
965
}
1012
966
 
1013
 
/****************************************************************//**
 
967
/********************************************************************
1014
968
Starts InnoDB and creates a new database if database files
1015
969
are not found and the user wants.
1016
970
@return DB_SUCCESS or error code */
1019
973
innobase_start_or_create_for_mysql(void)
1020
974
/*====================================*/
1021
975
{
1022
 
        buf_pool_t*     ret;
1023
976
        ibool           create_new_db;
1024
977
        ibool           log_file_created;
1025
978
        ibool           log_created     = FALSE;
1050
1003
        on Mac OS X 10.3 or later. */
1051
1004
        struct utsname utsname;
1052
1005
        if (uname(&utsname)) {
1053
 
                fputs("InnoDB: cannot determine Mac OS X version!\n", stderr);
 
1006
                fputs(_("InnoDB: cannot determine Mac OS X version!\n"), stderr);
1054
1007
        } else {
1055
1008
                srv_have_fullfsync = strcmp(utsname.release, "7.") >= 0;
1056
1009
        }
1057
1010
        if (!srv_have_fullfsync) {
1058
 
                fputs("InnoDB: On Mac OS X, fsync() may be"
1059
 
                      " broken on internal drives,\n"
1060
 
                      "InnoDB: making transactions unsafe!\n", stderr);
 
1011
                fputs(_("InnoDB: On Mac OS X, fsync() may be"
 
1012
                        " broken on internal drives,\n"
 
1013
                        "InnoDB: making transactions unsafe!\n"), stderr);
1061
1014
        }
1062
1015
# endif /* F_FULLFSYNC */
1063
1016
#endif /* HAVE_DARWIN_THREADS */
1064
1017
 
1065
1018
        if (sizeof(ulint) != sizeof(void*)) {
1066
 
                fprintf(stderr,
1067
 
                        "InnoDB: Error: size of InnoDB's ulint is %lu,"
1068
 
                        " but size of void* is %lu.\n"
1069
 
                        "InnoDB: The sizes should be the same"
1070
 
                        " so that on a 64-bit platform you can\n"
1071
 
                        "InnoDB: allocate more than 4 GB of memory.",
 
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."),
1072
1022
                        (ulong)sizeof(ulint), (ulong)sizeof(void*));
1073
1023
        }
1074
1024
 
1078
1028
        innodb_file_per_table) until this function has returned. */
1079
1029
        srv_file_per_table = FALSE;
1080
1030
#ifdef UNIV_DEBUG
1081
 
        fprintf(stderr,
1082
 
                "InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n");
 
1031
        drizzled::errmsg_printf(drizzled::error::INFO,
 
1032
                                _("InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n"));
1083
1033
#endif
1084
1034
 
1085
1035
#ifdef UNIV_IBUF_DEBUG
1086
 
        fprintf(stderr,
1087
 
                "InnoDB: !!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!\n"
1088
 
                "InnoDB: Crash recovery will fail with UNIV_IBUF_DEBUG\n");
 
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"
 
1041
# endif
 
1042
                ));
1089
1043
#endif
1090
1044
 
1091
1045
#ifdef UNIV_SYNC_DEBUG
1092
 
        fprintf(stderr,
1093
 
                "InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n");
 
1046
        drizzled::errmsg_printf(drizzled::error::INFO,
 
1047
                                _("InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!\n"));
1094
1048
#endif
1095
1049
 
1096
1050
#ifdef UNIV_SEARCH_DEBUG
1097
 
        fprintf(stderr,
1098
 
                "InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n");
 
1051
        drizzled::errmsg_printf(drizzled::error::INFO,
 
1052
                                _("InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n"));
1099
1053
#endif
1100
1054
 
 
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 */
1101
1059
#ifdef UNIV_MEM_DEBUG
1102
 
        fprintf(stderr,
1103
 
                "InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n");
 
1060
        drizzled::errmsg_printf(drizzled::error::INFO,
 
1061
                                _("InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n"));
1104
1062
#endif
1105
1063
 
1106
 
        if (UNIV_LIKELY(srv_use_sys_malloc)) {
1107
 
                fprintf(stderr,
1108
 
                        "InnoDB: The InnoDB memory heap is disabled\n");
 
1064
        if (UNIV_LIKELY(srv_use_sys_malloc))
 
1065
        {
 
1066
          drizzled::errmsg_printf(drizzled::error::ERROR, _("InnoDB: The InnoDB memory heap is disabled\n"));
1109
1067
        }
1110
1068
 
1111
 
#ifdef HAVE_GCC_ATOMIC_BUILTINS
1112
 
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1113
 
        fprintf(stderr,
1114
 
                "InnoDB: Mutexes and rw_locks use GCC atomic builtins.\n");
1115
 
# else /* INNODB_RW_LOCKS_USE_ATOMICS */
1116
 
        fprintf(stderr,
1117
 
                "InnoDB: Mutexes use GCC atomic builtins, rw_locks do not.\n");
1118
 
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1119
 
#elif defined(HAVE_SOLARIS_ATOMICS)
1120
 
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1121
 
        fprintf(stderr,
1122
 
                "InnoDB: Mutexes and rw_locks use Solaris atomic functions.\n");
1123
 
# else
1124
 
        fprintf(stderr,
1125
 
                "InnoDB: Mutexes use Solaris atomic functions.\n");
1126
 
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1127
 
#elif defined(HAVE_WINDOWS_ATOMICS)
1128
 
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1129
 
        fprintf(stderr,
1130
 
                "InnoDB: Mutexes and rw_locks use Windows interlocked functions.\n");
1131
 
# else
1132
 
        fprintf(stderr,
1133
 
                "InnoDB: Mutexes use Windows interlocked functions.\n");
1134
 
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1135
 
#else /* HAVE_GCC_ATOMIC_BUILTINS */
1136
 
        fprintf(stderr,
1137
 
                "InnoDB: Neither mutexes nor rw_locks use GCC atomic builtins.\n");
1138
 
#endif /* HAVE_GCC_ATOMIC_BUILTINS */
 
1069
        fputs("InnoDB: " IB_ATOMICS_STARTUP_MSG
 
1070
                "\nInnoDB: Compressed tables use zlib " ZLIB_VERSION
 
1071
#ifdef UNIV_ZIP_DEBUG
 
1072
              " with validation"
 
1073
#endif /* UNIV_ZIP_DEBUG */
 
1074
#ifdef UNIV_ZIP_COPY
 
1075
              " and extra copying"
 
1076
#endif /* UNIV_ZIP_COPY */
 
1077
              "\n" , stderr);
 
1078
 
1139
1079
 
1140
1080
        /* Since InnoDB does not currently clean up all its internal data
1141
1081
        structures in MySQL Embedded Server Library server_end(), we
1143
1083
        second time during the process lifetime. */
1144
1084
 
1145
1085
        if (srv_start_has_been_called) {
1146
 
                fprintf(stderr,
1147
 
                        "InnoDB: Error:startup called second time"
1148
 
                        " during the process lifetime.\n"
1149
 
                        "InnoDB: In the MySQL Embedded Server Library"
1150
 
                        " you cannot call server_init()\n"
1151
 
                        "InnoDB: more than once during"
1152
 
                        " the process lifetime.\n");
 
1086
          drizzled::errmsg_printf(drizzled::error::ERROR,
 
1087
                        "InnoDB: Error: startup called second time during the process lifetime.\n");
1153
1088
        }
1154
1089
 
1155
1090
        srv_start_has_been_called = TRUE;
1161
1096
 
1162
1097
        srv_is_being_started = TRUE;
1163
1098
        srv_startup_is_before_trx_rollback_phase = TRUE;
1164
 
        os_aio_use_native_aio = FALSE;
1165
1099
 
1166
1100
#ifdef __WIN__
1167
1101
        switch (os_get_os_version()) {
1173
1107
                but when run in conjunction with InnoDB Hot Backup, it seemed
1174
1108
                to corrupt the data files. */
1175
1109
 
1176
 
                os_aio_use_native_aio = FALSE;
1177
 
                break;
 
1110
                srv_use_native_aio = FALSE;
 
1111
                break;
 
1112
 
 
1113
        case OS_WIN2000:
 
1114
        case OS_WINXP:
 
1115
                /* On 2000 and XP, async IO is available. */
 
1116
                srv_use_native_aio = TRUE;
 
1117
                break;
 
1118
 
1178
1119
        default:
1179
 
                /* On Win 2000 and XP use async i/o */
1180
 
                os_aio_use_native_aio = TRUE;
 
1120
                /* Vista and later have both async IO and condition variables */
 
1121
                srv_use_native_aio = TRUE;
 
1122
                srv_use_native_conditions = TRUE;
1181
1123
                break;
1182
1124
        }
 
1125
 
 
1126
#elif defined(LINUX_NATIVE_AIO)
 
1127
 
 
1128
        if (srv_use_native_aio) {
 
1129
                drizzled::errmsg_printf(drizzled::error::INFO,
 
1130
                                        _("InnoDB: Using Linux native AIO"));
 
1131
        }
 
1132
#else
 
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;
 
1137
 
1183
1138
#endif
 
1139
 
1184
1140
        if (srv_file_flush_method_str == NULL) {
1185
1141
                /* These are the default options */
1186
1142
 
1205
1161
#else
1206
1162
        } else if (0 == ut_strcmp(srv_file_flush_method_str, "normal")) {
1207
1163
                srv_win_file_flush_method = SRV_WIN_IO_NORMAL;
1208
 
                os_aio_use_native_aio = FALSE;
 
1164
                srv_use_native_aio = FALSE;
1209
1165
 
1210
1166
        } else if (0 == ut_strcmp(srv_file_flush_method_str, "unbuffered")) {
1211
1167
                srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
1212
 
                os_aio_use_native_aio = FALSE;
 
1168
                srv_use_native_aio = FALSE;
1213
1169
 
1214
1170
        } else if (0 == ut_strcmp(srv_file_flush_method_str,
1215
1171
                                  "async_unbuffered")) {
1216
1172
                srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
1217
1173
#endif
1218
1174
        } else {
1219
 
                fprintf(stderr,
1220
 
                        "InnoDB: Unrecognized value %s for"
1221
 
                        " innodb_flush_method\n",
1222
 
                        srv_file_flush_method_str);
 
1175
          drizzled::errmsg_printf(drizzled::error::ERROR,
 
1176
                                  "InnoDB: Unrecognized value %s for innodb_flush_method",
 
1177
                                  srv_file_flush_method_str);
1223
1178
                return(DB_ERROR);
1224
1179
        }
1225
1180
 
1231
1186
        maximum number of threads that can wait in the 'srv_conc array' for
1232
1187
        their time to enter InnoDB. */
1233
1188
 
1234
 
#if defined(__NETWARE__)
1235
 
 
1236
 
        /* Create less event semaphores because Win 98/ME had
1237
 
        difficulty creating 40000 event semaphores.  Comment from
1238
 
        Novell, Inc.: also, these just take a lot of memory on
1239
 
        NetWare. */
1240
 
        srv_max_n_threads = 1000;
1241
 
#else
1242
1189
        if (srv_buf_pool_size >= 1000 * 1024 * 1024) {
1243
1190
                /* If buffer pool is less than 1000 MB,
1244
 
                assume fewer threads. */
 
1191
                assume fewer threads. Also use only one
 
1192
                buffer pool instance */
1245
1193
                srv_max_n_threads = 50000;
1246
1194
 
1247
1195
        } else if (srv_buf_pool_size >= 8 * 1024 * 1024) {
1248
1196
 
 
1197
                srv_buf_pool_instances = 1;
1249
1198
                srv_max_n_threads = 10000;
1250
1199
        } else {
 
1200
                srv_buf_pool_instances = 1;
1251
1201
                srv_max_n_threads = 1000;       /* saves several MB of memory,
1252
1202
                                                especially in 64-bit
1253
1203
                                                computers */
1254
1204
        }
1255
 
#endif
 
1205
 
1256
1206
        err = srv_boot();
1257
1207
 
1258
1208
        if (err != DB_SUCCESS) {
1260
1210
                return((int) err);
1261
1211
        }
1262
1212
 
1263
 
        mutex_create(&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
 
1213
        mutex_create(srv_monitor_file_mutex_key,
 
1214
                     &srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
1264
1215
 
1265
1216
        if (srv_innodb_status) {
1266
 
                srv_monitor_file_name = mem_alloc(
 
1217
          srv_monitor_file_name = static_cast<char *>(mem_alloc(
1267
1218
                        strlen(fil_path_to_mysql_datadir)
1268
 
                        + 20 + sizeof "/innodb_status.");
 
1219
                        + 20 + sizeof "/innodb_status."));
1269
1220
                sprintf(srv_monitor_file_name, "%s/innodb_status.%lu",
1270
1221
                        fil_path_to_mysql_datadir, os_proc_get_number());
1271
1222
                srv_monitor_file = fopen(srv_monitor_file_name, "w+");
1272
1223
                if (!srv_monitor_file) {
1273
 
                        fprintf(stderr, "InnoDB: unable to create %s: %s\n",
1274
 
                                srv_monitor_file_name, strerror(errno));
 
1224
                  drizzled::errmsg_printf(drizzled::error::ERROR,
 
1225
                                          "InnoDB: unable to create %s: %s\n", srv_monitor_file_name, strerror(errno));
1275
1226
                        return(DB_ERROR);
1276
1227
                }
1277
1228
        } else {
1282
1233
                }
1283
1234
        }
1284
1235
 
1285
 
        mutex_create(&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
 
1236
        mutex_create(srv_dict_tmpfile_mutex_key,
 
1237
                     &srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1286
1238
 
1287
1239
        srv_dict_tmpfile = os_file_create_tmpfile();
1288
1240
        if (!srv_dict_tmpfile) {
1289
1241
                return(DB_ERROR);
1290
1242
        }
1291
1243
 
1292
 
        mutex_create(&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
 
1244
        mutex_create(srv_misc_tmpfile_mutex_key,
 
1245
                     &srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1293
1246
 
1294
1247
        srv_misc_tmpfile = os_file_create_tmpfile();
1295
1248
        if (!srv_misc_tmpfile) {
1296
1249
                return(DB_ERROR);
1297
1250
        }
1298
1251
 
1299
 
        /* If user has set the value of innodb_file_io_threads then
1300
 
        we'll emit a message telling the user that this parameter
1301
 
        is now deprecated. */
1302
 
        if (srv_n_file_io_threads != 4) {
1303
 
                fprintf(stderr, "InnoDB: Warning:"
1304
 
                        " innodb_file_io_threads is deprecated."
1305
 
                        " Please use innodb_read_io_threads and"
1306
 
                        " innodb_write_io_threads instead\n");
1307
 
        }
 
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. */
1308
1255
 
1309
1256
        /* Now overwrite the value on srv_n_file_io_threads */
1310
1257
        srv_n_file_io_threads = 2 + srv_n_read_io_threads
1314
1261
 
1315
1262
        /* TODO: Investigate if SRV_N_PENDING_IOS_PER_THREAD (32) limit
1316
1263
        still applies to windows. */
1317
 
        if (!os_aio_use_native_aio) {
 
1264
        if (!srv_use_native_aio) {
1318
1265
                io_limit = 8 * SRV_N_PENDING_IOS_PER_THREAD;
1319
1266
        } else {
1320
1267
                io_limit = SRV_N_PENDING_IOS_PER_THREAD;
1328
1275
        fil_init(srv_file_per_table ? 50000 : 5000,
1329
1276
                 srv_max_n_open_files);
1330
1277
 
1331
 
        ret = buf_pool_init();
1332
 
 
1333
 
        if (ret == NULL) {
1334
 
                fprintf(stderr,
1335
 
                        "InnoDB: Fatal error: cannot allocate the memory"
1336
 
                        " for the buffer pool\n");
1337
 
 
1338
 
                return(DB_ERROR);
 
1278
        /* Print time to initialize the buffer pool */
 
1279
 
 
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));
 
1283
        } else {
 
1284
          drizzled::errmsg_printf(drizzled::error::INFO, "InnoDB: Initializing buffer pool, size = %.1fM",
 
1285
                                  ((double) srv_buf_pool_size) / (1024 * 1024));
 
1286
        }
 
1287
 
 
1288
        err = buf_pool_init(srv_buf_pool_size, srv_buf_pool_instances);
 
1289
 
 
1290
        drizzled::errmsg_printf(drizzled::error::INFO, "InnoDB: Completed initialization of buffer pool");
 
1291
 
 
1292
        if (err != DB_SUCCESS) {
 
1293
          drizzled::errmsg_printf(drizzled::error::ERROR, "InnoDB: Fatal error: cannot allocate the memory for the buffer pool");
 
1294
 
 
1295
          return(DB_ERROR);
1339
1296
        }
1340
1297
 
1341
1298
#ifdef UNIV_DEBUG
1344
1301
 
1345
1302
        if (srv_buf_pool_size <= 5 * 1024 * 1024) {
1346
1303
 
1347
 
                fprintf(stderr, "InnoDB: Warning: Small buffer pool size "
1348
 
                        "(%luM), the flst_validate() debug function "
1349
 
                        "can cause a deadlock if the buffer pool fills up.\n",
1350
 
                        srv_buf_pool_size / 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);
1351
1308
        }
1352
1309
#endif
1353
1310
 
1366
1323
 
1367
1324
#ifdef UNIV_LOG_ARCHIVE
1368
1325
        if (0 != ut_strcmp(srv_log_group_home_dirs[0], srv_arch_dir)) {
1369
 
                fprintf(stderr,
1370
 
                        "InnoDB: Error: you must set the log group"
1371
 
                        " home dir in my.cnf the\n"
1372
 
                        "InnoDB: same as log arch dir.\n");
 
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.");
1373
1328
 
1374
1329
                return(DB_ERROR);
1375
1330
        }
1376
1331
#endif /* UNIV_LOG_ARCHIVE */
1377
1332
 
1378
1333
        if (srv_n_log_files * srv_log_file_size >= 262144) {
1379
 
                fprintf(stderr,
1380
 
                        "InnoDB: Error: combined size of log files"
1381
 
                        " must be < 4 GB\n");
 
1334
          drizzled::errmsg_printf(drizzled::error::ERROR,
 
1335
                                  "InnoDB: Error: combined size of log files must be < 4 GB");
1382
1336
 
1383
1337
                return(DB_ERROR);
1384
1338
        }
1388
1342
        for (i = 0; i < srv_n_data_files; i++) {
1389
1343
#ifndef __WIN__
1390
1344
                if (sizeof(off_t) < 5 && srv_data_file_sizes[i] >= 262144) {
1391
 
                        fprintf(stderr,
1392
 
                                "InnoDB: Error: file size must be < 4 GB"
1393
 
                                " with this MySQL binary\n"
1394
 
                                "InnoDB: and operating system combination,"
1395
 
                                " in some OS's < 2 GB\n");
 
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");
1396
1348
 
1397
1349
                        return(DB_ERROR);
1398
1350
                }
1400
1352
                sum_of_new_sizes += srv_data_file_sizes[i];
1401
1353
        }
1402
1354
 
1403
 
        if (sum_of_new_sizes < 640) {
1404
 
                fprintf(stderr,
1405
 
                        "InnoDB: Error: tablespace size must be"
1406
 
                        " at least 10 MB\n");
 
1355
        if (sum_of_new_sizes < 10485760 / UNIV_PAGE_SIZE) {
 
1356
          drizzled::errmsg_printf(drizzled::error::ERROR, "InnoDB: Error: tablespace size must be at least 10 MB");
1407
1357
 
1408
1358
                return(DB_ERROR);
1409
1359
        }
1415
1365
                                        &min_flushed_lsn, &max_flushed_lsn,
1416
1366
                                        &sum_of_new_sizes);
1417
1367
        if (err != DB_SUCCESS) {
1418
 
                fprintf(stderr,
1419
 
                        "InnoDB: Could not open or create data files.\n"
1420
 
                        "InnoDB: If you tried to add new data files,"
1421
 
                        " and it failed here,\n"
1422
 
                        "InnoDB: you should now edit innodb_data_file_path"
1423
 
                        " in my.cnf back\n"
1424
 
                        "InnoDB: to what it was, and remove the"
1425
 
                        " new ibdata files InnoDB created\n"
1426
 
                        "InnoDB: in this failed attempt. InnoDB only wrote"
1427
 
                        " those files full of\n"
1428
 
                        "InnoDB: zeros, but did not yet use them in any way."
1429
 
                        " But be careful: do not\n"
1430
 
                        "InnoDB: remove old data files"
1431
 
                        " which contain your precious data!\n");
 
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");
1432
1376
 
1433
1377
                return((int) err);
1434
1378
        }
1453
1397
                }
1454
1398
                if ((log_opened && create_new_db)
1455
1399
                    || (log_opened && log_created)) {
1456
 
                        fprintf(stderr,
1457
 
                                "InnoDB: Error: all log files must be"
1458
 
                                " created at the same time.\n"
1459
 
                                "InnoDB: All log files must be"
1460
 
                                " created also in database creation.\n"
1461
 
                                "InnoDB: If you want bigger or smaller"
1462
 
                                " log files, shut down the\n"
1463
 
                                "InnoDB: database and make sure there"
1464
 
                                " were no errors in shutdown.\n"
1465
 
                                "InnoDB: Then delete the existing log files."
1466
 
                                " Edit the .cnf file\n"
 
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"
1467
1406
                                "InnoDB: and start the database again.\n");
1468
1407
 
1469
1408
                        return(DB_ERROR);
1485
1424
                    || max_arch_log_no != min_arch_log_no
1486
1425
#endif /* UNIV_LOG_ARCHIVE */
1487
1426
                    ) {
1488
 
                        fprintf(stderr,
1489
 
                                "InnoDB: Cannot initialize created"
1490
 
                                " log files because\n"
1491
 
                                "InnoDB: data files were not in sync"
1492
 
                                " with each other\n"
 
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"
1493
1430
                                "InnoDB: or the data files are corrupt.\n");
1494
1431
 
1495
1432
                        return(DB_ERROR);
1496
1433
                }
1497
1434
 
1498
1435
                if (max_flushed_lsn < (ib_uint64_t) 1000) {
1499
 
                        fprintf(stderr,
1500
 
                                "InnoDB: Cannot initialize created"
1501
 
                                " log files because\n"
1502
 
                                "InnoDB: data files are corrupt,"
1503
 
                                " or new data files were\n"
1504
 
                                "InnoDB: created when the database"
1505
 
                                " was started previous\n"
1506
 
                                "InnoDB: time but the database"
1507
 
                                " was not shut down\n"
1508
 
                                "InnoDB: normally after that.\n");
 
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");
1509
1442
 
1510
1443
                        return(DB_ERROR);
1511
1444
                }
1527
1460
 
1528
1461
        if (create_new_db) {
1529
1462
                mtr_start(&mtr);
 
1463
 
1530
1464
                fsp_header_init(0, sum_of_new_sizes, &mtr);
1531
1465
 
1532
1466
                mtr_commit(&mtr);
1533
1467
 
 
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. */
1534
1472
                trx_sys_create();
 
1473
 
1535
1474
                dict_create();
 
1475
 
1536
1476
                srv_startup_is_before_trx_rollback_phase = FALSE;
1537
1477
 
1538
1478
#ifdef UNIV_LOG_ARCHIVE
1539
1479
        } else if (srv_archive_recovery) {
1540
 
                fprintf(stderr,
1541
 
                        "InnoDB: Starting archive"
1542
 
                        " recovery from a backup...\n");
 
1480
          drizzled::errmsg_printf(drizzled::error::INFO,
 
1481
                                  "InnoDB: Starting archive recovery from a backup...");
1543
1482
                err = recv_recovery_from_archive_start(
1544
1483
                        min_flushed_lsn, srv_archive_recovery_limit_lsn,
1545
1484
                        min_arch_log_no);
1551
1490
                in any disk i/o, first call dict_boot */
1552
1491
 
1553
1492
                dict_boot();
 
1493
 
1554
1494
                trx_sys_init_at_db_start();
 
1495
 
1555
1496
                srv_startup_is_before_trx_rollback_phase = FALSE;
1556
1497
 
1557
1498
                /* Initialize the fsp free limit global variable in the log
1575
1516
                consistent state, this is REQUIRED for the recovery
1576
1517
                process to work. */
1577
1518
                err = trx_sys_file_format_max_check(
1578
 
                        srv_check_file_format_at_startup);
 
1519
                        srv_max_file_format_at_startup);
1579
1520
 
1580
1521
                if (err != DB_SUCCESS) {
1581
1522
                        return(err);
1609
1550
                dict_boot();
1610
1551
                trx_sys_init_at_db_start();
1611
1552
 
 
1553
                /* Initialize the fsp free limit global variable in the log
 
1554
                system */
 
1555
                fsp_header_get_free_limit();
 
1556
 
 
1557
                /* recv_recovery_from_checkpoint_finish needs trx lists which
 
1558
                are initialized in trx_sys_init_at_db_start(). */
 
1559
 
 
1560
                recv_recovery_from_checkpoint_finish();
1612
1561
                if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
1613
1562
                        /* The following call is necessary for the insert
1614
1563
                        buffer to work with multiple tablespaces. We must
1624
1573
                        every table in the InnoDB data dictionary that has
1625
1574
                        an .ibd file.
1626
1575
 
1627
 
                        We also determine the maximum tablespace id used.
1628
 
 
1629
 
                        TODO: We may have incomplete transactions in the
1630
 
                        data dictionary tables. Does that harm the scanning of
1631
 
                        the data dictionary below? */
 
1576
                        We also determine the maximum tablespace id used. */
1632
1577
 
1633
1578
                        dict_check_tablespaces_and_store_max_id(
1634
1579
                                recv_needed_recovery);
1635
1580
                }
1636
1581
 
1637
1582
                srv_startup_is_before_trx_rollback_phase = FALSE;
1638
 
 
1639
 
                /* Initialize the fsp free limit global variable in the log
1640
 
                system */
1641
 
                fsp_header_get_free_limit();
1642
 
 
1643
 
                /* recv_recovery_from_checkpoint_finish needs trx lists which
1644
 
                are initialized in trx_sys_init_at_db_start(). */
1645
 
 
1646
 
                recv_recovery_from_checkpoint_finish();
 
1583
                recv_recovery_rollback_active();
1647
1584
 
1648
1585
                /* It is possible that file_format tag has never
1649
1586
                been set. In this case we initialize it to minimum
1692
1629
        /* fprintf(stderr, "Max allowed record size %lu\n",
1693
1630
        page_get_free_space_of_empty() / 2); */
1694
1631
 
1695
 
        /* Create the thread which watches the timeouts for lock waits
1696
 
        and prints InnoDB monitor info */
1697
 
 
1698
 
        os_thread_create(&srv_lock_timeout_and_monitor_thread, NULL,
 
1632
        if (trx_doublewrite == NULL) {
 
1633
                /* Create the doublewrite buffer to a new tablespace */
 
1634
 
 
1635
                trx_sys_create_doublewrite_buf();
 
1636
        }
 
1637
 
 
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. */
 
1643
 
 
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. */
 
1650
 
 
1651
        trx_sys_create_rsegs(TRX_SYS_N_RSEGS - 1);
 
1652
 
 
1653
        /* Create the thread which watches the timeouts for lock waits */
 
1654
        os_thread_create(&srv_lock_timeout_thread, NULL,
1699
1655
                         thread_ids + 2 + SRV_MAX_N_IO_THREADS);
1700
1656
 
1701
1657
        /* Create the thread which warns of long semaphore waits */
1702
1658
        os_thread_create(&srv_error_monitor_thread, NULL,
1703
1659
                         thread_ids + 3 + SRV_MAX_N_IO_THREADS);
 
1660
 
 
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);
 
1664
 
1704
1665
        srv_is_being_started = FALSE;
1705
1666
 
1706
 
        if (trx_doublewrite == NULL) {
1707
 
                /* Create the doublewrite buffer to a new tablespace */
1708
 
 
1709
 
                trx_sys_create_doublewrite_buf();
1710
 
        }
1711
 
 
1712
1667
        err = dict_create_or_check_foreign_constraint_tables();
1713
1668
 
1714
1669
        if (err != DB_SUCCESS) {
1720
1675
 
1721
1676
        os_thread_create(&srv_master_thread, NULL, thread_ids
1722
1677
                         + (1 + SRV_MAX_N_IO_THREADS));
 
1678
 
 
1679
        /* Currently we allow only a single purge thread. */
 
1680
        ut_a(srv_n_purge_threads == 0 || srv_n_purge_threads == 1);
 
1681
 
 
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);
 
1686
        }
 
1687
 
1723
1688
#ifdef UNIV_DEBUG
1724
1689
        /* buf_debug_prints = TRUE; */
1725
1690
#endif /* UNIV_DEBUG */
1734
1699
        if (!srv_auto_extend_last_data_file
1735
1700
            && sum_of_data_file_sizes != tablespace_size_in_header) {
1736
1701
 
1737
 
                fprintf(stderr,
1738
 
                        "InnoDB: Error: tablespace size"
1739
 
                        " stored in header is %lu pages, but\n"
1740
 
                        "InnoDB: the sum of data file sizes is %lu pages\n",
1741
 
                        (ulong) tablespace_size_in_header,
1742
 
                        (ulong) sum_of_data_file_sizes);
 
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);
1743
1706
 
1744
1707
                if (srv_force_recovery == 0
1745
1708
                    && sum_of_data_file_sizes < tablespace_size_in_header) {
1746
1709
                        /* This is a fatal error, the tail of a tablespace is
1747
1710
                        missing */
1748
1711
 
1749
 
                        fprintf(stderr,
1750
 
                                "InnoDB: Cannot start InnoDB."
1751
 
                                " The tail of the system tablespace is\n"
1752
 
                                "InnoDB: missing. Have you edited"
1753
 
                                " innodb_data_file_path in my.cnf in an\n"
1754
 
                                "InnoDB: inappropriate way, removing"
1755
 
                                " ibdata files from there?\n"
1756
 
                                "InnoDB: You can set innodb_force_recovery=1"
1757
 
                                " in my.cnf to force\n"
1758
 
                                "InnoDB: a startup if you are trying"
1759
 
                                " to recover a badly corrupt database.\n");
 
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.");
1760
1718
 
1761
1719
                        return(DB_ERROR);
1762
1720
                }
1765
1723
        if (srv_auto_extend_last_data_file
1766
1724
            && sum_of_data_file_sizes < tablespace_size_in_header) {
1767
1725
 
1768
 
                fprintf(stderr,
1769
 
                        "InnoDB: Error: tablespace size stored in header"
1770
 
                        " is %lu pages, but\n"
1771
 
                        "InnoDB: the sum of data file sizes"
1772
 
                        " is only %lu pages\n",
1773
 
                        (ulong) tablespace_size_in_header,
1774
 
                        (ulong) sum_of_data_file_sizes);
 
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);
1775
1731
 
1776
1732
                if (srv_force_recovery == 0) {
1777
1733
 
1778
 
                        fprintf(stderr,
1779
 
                                "InnoDB: Cannot start InnoDB. The tail of"
1780
 
                                " the system tablespace is\n"
1781
 
                                "InnoDB: missing. Have you edited"
1782
 
                                " innodb_data_file_path in my.cnf in an\n"
1783
 
                                "InnoDB: inappropriate way, removing"
1784
 
                                " ibdata files from there?\n"
1785
 
                                "InnoDB: You can set innodb_force_recovery=1"
1786
 
                                " in my.cnf to force\n"
1787
 
                                "InnoDB: a startup if you are trying to"
1788
 
                                " recover a badly corrupt database.\n");
 
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");
1789
1740
 
1790
1741
                        return(DB_ERROR);
1791
1742
                }
1795
1746
        os_fast_mutex_init(&srv_os_test_mutex);
1796
1747
 
1797
1748
        if (0 != os_fast_mutex_trylock(&srv_os_test_mutex)) {
1798
 
                fprintf(stderr,
1799
 
                        "InnoDB: Error: pthread_mutex_trylock returns"
1800
 
                        " an unexpected value on\n"
1801
 
                        "InnoDB: success! Cannot continue.\n");
 
1749
          drizzled::errmsg_printf(drizzled::error::ERROR,
 
1750
                        "InnoDB: Error: pthread_mutex_trylock returns an unexpected value on success! Cannot continue.\n");
1802
1751
                exit(1);
1803
1752
        }
1804
1753
 
1811
1760
        os_fast_mutex_free(&srv_os_test_mutex);
1812
1761
 
1813
1762
        if (srv_print_verbose_log) {
1814
 
                ut_print_timestamp(stderr);
1815
 
                fprintf(stderr,
1816
 
                        " InnoDB Plugin %s started; "
1817
 
                        "log sequence number %"PRIu64"\n",
1818
 
                        INNODB_VERSION_STR, srv_start_lsn);
 
1763
                drizzled::errmsg_printf(drizzled::error::ERROR,
 
1764
                                        "InnoDB %s started; log sequence number %"PRIu64"\n",
 
1765
                                        INNODB_VERSION_STR, srv_start_lsn);
1819
1766
        }
1820
1767
 
1821
1768
        if (srv_force_recovery > 0) {
1822
 
                fprintf(stderr,
1823
 
                        "InnoDB: !!! innodb_force_recovery"
1824
 
                        " is set to %lu !!!\n",
1825
 
                        (ulong) srv_force_recovery);
 
1769
          drizzled::errmsg_printf(drizzled::error::ERROR,
 
1770
                                  "InnoDB: !!! innodb_force_recovery is set to %lu !!!\n",
 
1771
                                  (ulong) srv_force_recovery);
1826
1772
        }
1827
1773
 
1828
 
        fflush(stderr);
1829
 
 
1830
1774
        if (trx_doublewrite_must_reset_space_ids) {
1831
1775
                /* Actually, we did not change the undo log format between
1832
1776
                4.0 and 4.1.1, and we would not need to run purge to
1841
1785
                4.1.1. It is essential that the insert buffer is emptied
1842
1786
                here! */
1843
1787
 
1844
 
                fprintf(stderr,
1845
 
                        "InnoDB: You are upgrading to an"
1846
 
                        " InnoDB version which allows multiple\n"
1847
 
                        "InnoDB: tablespaces. Wait that purge"
1848
 
                        " and insert buffer merge run to\n"
1849
 
                        "InnoDB: completion...\n");
 
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...");
1850
1791
                for (;;) {
1851
1792
                        os_thread_sleep(1000000);
1852
1793
 
1858
1799
                                break;
1859
1800
                        }
1860
1801
                }
1861
 
                fprintf(stderr,
1862
 
                        "InnoDB: Full purge and insert buffer merge"
1863
 
                        " completed.\n");
 
1802
                drizzled::errmsg_printf(drizzled::error::INFO,
 
1803
                                        "InnoDB: Full purge and insert buffer merge completed.");
1864
1804
 
1865
1805
                trx_sys_mark_upgraded_to_multiple_tablespaces();
1866
1806
 
1867
 
                fprintf(stderr,
1868
 
                        "InnoDB: You have now successfully upgraded"
1869
 
                        " to the multiple tablespaces\n"
1870
 
                        "InnoDB: format. You should NOT DOWNGRADE"
1871
 
                        " to an earlier version of\n"
1872
 
                        "InnoDB: InnoDB! But if you absolutely need to"
1873
 
                        " downgrade, see\n"
1874
 
                        "InnoDB: " REFMAN "multiple-tablespaces.html\n"
1875
 
                        "InnoDB: for instructions.\n");
 
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"
 
1813
                                        " downgrade, see\n"
 
1814
                                        "InnoDB: " REFMAN "multiple-tablespaces.html\n"
 
1815
                                        "InnoDB: for instructions.\n");
1876
1816
        }
1877
1817
 
1878
1818
        if (srv_force_recovery == 0) {
1900
1840
/*=============================*/
1901
1841
{
1902
1842
        ulint   i;
1903
 
#ifdef __NETWARE__
1904
 
        extern ibool panic_shutdown;
1905
 
#endif
1906
1843
        if (!srv_was_started) {
1907
1844
                if (srv_is_being_started) {
1908
 
                        ut_print_timestamp(stderr);
1909
 
                        fprintf(stderr,
1910
 
                                "  InnoDB: Warning: shutting down"
1911
 
                                " a not properly started\n"
1912
 
                                "InnoDB: or created database!\n");
 
1845
                  drizzled::errmsg_printf(drizzled::error::ERROR,
 
1846
                                "InnoDB: Warning: shutting down a not properly started or created database!");
1913
1847
                }
1914
1848
 
1915
1849
                return(DB_SUCCESS);
1922
1856
 
1923
1857
 
1924
1858
        if (srv_fast_shutdown == 2) {
1925
 
                ut_print_timestamp(stderr);
1926
 
                fprintf(stderr,
1927
 
                        "  InnoDB: MySQL has requested a very fast shutdown"
1928
 
                        " without flushing "
1929
 
                        "the InnoDB buffer pool to data files."
1930
 
                        " At the next mysqld startup "
1931
 
                        "InnoDB will do a crash recovery!\n");
 
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!");
1932
1863
        }
1933
1864
 
1934
 
#ifdef __NETWARE__
1935
 
        if (!panic_shutdown)
1936
 
#endif
1937
 
                logs_empty_and_mark_files_at_shutdown();
 
1865
        logs_empty_and_mark_files_at_shutdown();
1938
1866
 
1939
1867
        if (srv_conc_n_threads != 0) {
1940
 
                fprintf(stderr,
1941
 
                        "InnoDB: Warning: query counter shows %ld queries"
1942
 
                        " still\n"
1943
 
                        "InnoDB: inside InnoDB at shutdown\n",
1944
 
                        srv_conc_n_threads);
 
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);
1945
1871
        }
1946
1872
 
1947
1873
        /* 2. Make all threads created by InnoDB to exit */
1973
1899
                /* c. We wake the master thread so that it exits */
1974
1900
                srv_wake_master_thread();
1975
1901
 
1976
 
                /* d. Exit the i/o threads */
 
1902
                /* d. We wake the purge thread so that it exits */
 
1903
                srv_wake_purge_thread();
 
1904
 
 
1905
                /* e. Exit the i/o threads */
1977
1906
 
1978
1907
                os_aio_wake_all_threads_at_shutdown();
1979
1908
 
1983
1912
                        /* All the threads have exited or are just exiting;
1984
1913
                        NOTE that the threads may not have completed their
1985
1914
                        exit yet. Should we use pthread_join() to make sure
1986
 
                        they have exited? Now we just sleep 0.1 seconds and
1987
 
                        hope that is enough! */
 
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! */
1988
1919
 
1989
1920
                        os_mutex_exit(os_sync_mutex);
1990
1921
 
1999
1930
        }
2000
1931
 
2001
1932
        if (i == 1000) {
2002
 
                fprintf(stderr,
2003
 
                        "InnoDB: Warning: %lu threads created by InnoDB"
2004
 
                        " had not exited at shutdown!\n",
 
1933
          drizzled::errmsg_printf(drizzled::error::WARN,
 
1934
                        "InnoDB: Warning: %lu threads created by InnoDB had not exited at shutdown!",
2005
1935
                        (ulong) os_thread_count);
2006
1936
        }
2007
1937
 
2023
1953
                srv_misc_tmpfile = 0;
2024
1954
        }
2025
1955
 
 
1956
        /* This must be disabled before closing the buffer pool
 
1957
        and closing the data dictionary.  */
 
1958
        btr_search_disable();
 
1959
 
 
1960
        ibuf_close();
 
1961
        log_shutdown();
 
1962
        lock_sys_close();
 
1963
        thr_local_close();
2026
1964
        trx_sys_file_format_close();
 
1965
        trx_sys_close();
2027
1966
 
2028
1967
        mutex_free(&srv_monitor_file_mutex);
2029
1968
        mutex_free(&srv_dict_tmpfile_mutex);
2030
1969
        mutex_free(&srv_misc_tmpfile_mutex);
 
1970
        dict_close();
 
1971
        btr_search_sys_free();
2031
1972
 
2032
1973
        /* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
2033
1974
        them */
 
1975
        os_aio_free();
2034
1976
        sync_close();
 
1977
        srv_free();
 
1978
        fil_close();
2035
1979
 
2036
1980
        /* 4. Free the os_conc_mutex and all os_events and os_mutexes */
2037
1981
 
2038
 
        srv_free();
2039
1982
        os_sync_free();
2040
1983
 
2041
 
        /* Check that all read views are closed except read view owned
2042
 
        by a purge. */
2043
 
 
2044
 
        if (UT_LIST_GET_LEN(trx_sys->view_list) > 1) {
2045
 
                fprintf(stderr,
2046
 
                        "InnoDB: Error: all read views were not closed"
2047
 
                        " before shutdown:\n"
2048
 
                        "InnoDB: %lu read views open \n",
2049
 
                        UT_LIST_GET_LEN(trx_sys->view_list) - 1);
2050
 
        }
2051
 
 
2052
 
        /* 5. Free all allocated memory and the os_fast_mutex created in
2053
 
        ut0mem.c */
2054
 
 
2055
 
        buf_pool_free();
 
1984
        /* 5. Free all allocated memory */
 
1985
 
 
1986
        pars_lexer_close();
 
1987
        log_mem_free();
 
1988
        buf_pool_free(srv_buf_pool_instances);
 
1989
        mem_close();
 
1990
 
 
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 */
2056
1994
        ut_free_all_mem();
2057
1995
 
2058
1996
        if (os_thread_count != 0
2059
1997
            || os_event_count != 0
2060
1998
            || os_mutex_count != 0
2061
1999
            || os_fast_mutex_count != 0) {
2062
 
                fprintf(stderr,
2063
 
                        "InnoDB: Warning: some resources were not"
2064
 
                        " cleaned up in shutdown:\n"
2065
 
                        "InnoDB: threads %lu, events %lu,"
2066
 
                        " os_mutexes %lu, os_fast_mutexes %lu\n",
2067
 
                        (ulong) os_thread_count, (ulong) os_event_count,
2068
 
                        (ulong) os_mutex_count, (ulong) os_fast_mutex_count);
 
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);
2069
2005
        }
2070
2006
 
2071
2007
        if (dict_foreign_err_file) {
2076
2012
        }
2077
2013
 
2078
2014
        if (srv_print_verbose_log) {
2079
 
                ut_print_timestamp(stderr);
2080
 
                fprintf(stderr,
2081
 
                        "  InnoDB: Shutdown completed;"
2082
 
                        " log sequence number %"PRIu64"\n",
2083
 
                        srv_shutdown_lsn);
 
2015
                drizzled::errmsg_printf(drizzled::error::INFO,
 
2016
                                        "InnoDB: Shutdown completed log sequence number %"PRIu64,
 
2017
                                        srv_shutdown_lsn);
2084
2018
        }
2085
2019
 
2086
2020
        srv_was_started = FALSE;
 
2021
        srv_start_has_been_called = FALSE;
2087
2022
 
2088
2023
        return((int) DB_SUCCESS);
2089
2024
}
2090
 
 
2091
 
#ifdef __NETWARE__
2092
 
void set_panic_flag_for_netware()
2093
 
{
2094
 
        extern ibool panic_shutdown;
2095
 
        panic_shutdown = TRUE;
2096
 
}
2097
 
#endif /* __NETWARE__ */
2098
2025
#endif /* !UNIV_HOTBACKUP */