~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: lbieber
  • Date: 2010-10-01 13:06:31 UTC
  • mfrom: (1802.2.2 drizzle-bug-651948)
  • mto: This revision was merged to the branch mainline in revision 1805.
  • Revision ID: lbieber@orisndriz08-20101001130631-xubscnhmj7r5dn6g
Merge Andrew - Fix bug 651948 - Index lengths not retrieved using drizzledump

Show diffs side-by-side

added added

removed removed

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