~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-12-06 01:55:53 UTC
  • mfrom: (1238.1.5 push)
  • Revision ID: brian@gaz-20091206015553-cva833q4gvwj11ob
Bundle for staging.

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