~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-01-17 02:46:52 UTC
  • Revision ID: brian@gir-3.local-20090117024652-4ducefje08ajbs1q
Refactor append_identifier and remove dead OPTION_QUOTE_SHOW_CREATE option
(we always quote).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
4
 
Copyright (c) 2008, Google Inc.
5
 
 
6
 
Portions of this file contain modifications contributed and copyrighted by
7
 
Google, Inc. Those modifications are gratefully acknowledged and are described
8
 
briefly in the InnoDB documentation. The contributions by Google are
9
 
incorporated with their permission, and subject to the conditions contained in
10
 
the file COPYING.Google.
11
 
 
12
 
This program is free software; you can redistribute it and/or modify it under
13
 
the terms of the GNU General Public License as published by the Free Software
14
 
Foundation; version 2 of the License.
15
 
 
16
 
This program is distributed in the hope that it will be useful, but WITHOUT
17
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19
 
 
20
 
You should have received a copy of the GNU General Public License along with
21
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22
 
Place, Suite 330, Boston, MA 02111-1307 USA
23
 
 
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
 
***********************************************************************/
51
 
 
52
 
/********************************************************************//**
53
 
@file srv/srv0start.c
 
1
/************************************************************************
54
2
Starts the InnoDB database server
55
3
 
 
4
(c) 1996-2000 Innobase Oy
 
5
 
56
6
Created 2/16/1996 Heikki Tuuri
57
7
*************************************************************************/
58
8
 
 
9
#include "os0proc.h"
 
10
#include "sync0sync.h"
59
11
#include "ut0mem.h"
60
12
#include "mem0mem.h"
 
13
#include "mem0pool.h"
61
14
#include "data0data.h"
62
15
#include "data0type.h"
63
16
#include "dict0dict.h"
64
17
#include "buf0buf.h"
 
18
#include "buf0flu.h"
 
19
#include "buf0rea.h"
65
20
#include "os0file.h"
66
21
#include "os0thread.h"
67
22
#include "fil0fil.h"
68
23
#include "fsp0fsp.h"
69
24
#include "rem0rec.h"
 
25
#include "rem0cmp.h"
70
26
#include "mtr0mtr.h"
71
27
#include "log0log.h"
72
28
#include "log0recv.h"
73
29
#include "page0page.h"
74
30
#include "page0cur.h"
75
31
#include "trx0trx.h"
 
32
#include "dict0boot.h"
 
33
#include "dict0load.h"
76
34
#include "trx0sys.h"
 
35
#include "dict0crea.h"
77
36
#include "btr0btr.h"
 
37
#include "btr0pcur.h"
78
38
#include "btr0cur.h"
 
39
#include "btr0sea.h"
79
40
#include "rem0rec.h"
 
41
#include "srv0srv.h"
 
42
#include "que0que.h"
 
43
#include "usr0sess.h"
 
44
#include "lock0lock.h"
 
45
#include "trx0roll.h"
 
46
#include "trx0purge.h"
 
47
#include "row0ins.h"
 
48
#include "row0sel.h"
 
49
#include "row0upd.h"
 
50
#include "row0row.h"
 
51
#include "row0mysql.h"
 
52
#include "lock0lock.h"
80
53
#include "ibuf0ibuf.h"
 
54
#include "pars0pars.h"
 
55
#include "btr0sea.h"
81
56
#include "srv0start.h"
82
 
#include "srv0srv.h"
83
 
#ifndef UNIV_HOTBACKUP
84
 
# include "os0proc.h"
85
 
# include "sync0sync.h"
86
 
# include "buf0flu.h"
87
 
# include "buf0rea.h"
88
 
# include "dict0boot.h"
89
 
# include "dict0load.h"
90
 
# include "que0que.h"
91
 
# include "usr0sess.h"
92
 
# include "lock0lock.h"
93
 
# include "trx0roll.h"
94
 
# include "trx0purge.h"
95
 
# include "lock0lock.h"
96
 
# include "pars0pars.h"
97
 
# include "btr0sea.h"
98
 
# include "rem0cmp.h"
99
 
# include "dict0crea.h"
100
 
# include "row0ins.h"
101
 
# include "row0sel.h"
102
 
# include "row0upd.h"
103
 
# include "row0row.h"
104
 
# include "row0mysql.h"
105
 
# include "btr0pcur.h"
106
 
 
107
 
#include <errno.h>
108
 
#include <unistd.h>
109
 
 
110
 
/** Log sequence number immediately after startup */
 
57
#include "que0que.h"
 
58
 
 
59
/* Log sequence number immediately after startup */
111
60
UNIV_INTERN ib_uint64_t srv_start_lsn;
112
 
/** Log sequence number at shutdown */
 
61
/* Log sequence number at shutdown */
113
62
UNIV_INTERN ib_uint64_t srv_shutdown_lsn;
114
63
 
115
64
#ifdef HAVE_DARWIN_THREADS
116
65
# include <sys/utsname.h>
117
 
/** TRUE if the F_FULLFSYNC option is available */
118
66
UNIV_INTERN ibool       srv_have_fullfsync = FALSE;
119
67
#endif
120
68
 
121
 
/** TRUE if a raw partition is in use */
122
69
UNIV_INTERN ibool       srv_start_raw_disk_in_use = FALSE;
123
70
 
124
 
/** TRUE if the server is being started, before rolling back any
125
 
incomplete transactions */
126
71
UNIV_INTERN ibool       srv_startup_is_before_trx_rollback_phase = FALSE;
127
 
/** TRUE if the server is being started */
128
72
UNIV_INTERN ibool       srv_is_being_started = FALSE;
129
 
/** TRUE if the server was successfully started */
130
73
UNIV_INTERN ibool       srv_was_started = FALSE;
131
 
/** TRUE if innobase_start_or_create_for_mysql() has been called */
 
74
#ifndef UNIV_HOTBACKUP
132
75
static ibool    srv_start_has_been_called = FALSE;
133
 
 
134
 
/** At a shutdown this value climbs from SRV_SHUTDOWN_NONE to
135
 
SRV_SHUTDOWN_CLEANUP and then to SRV_SHUTDOWN_LAST_PHASE, and so on */
136
 
UNIV_INTERN enum srv_shutdown_state     srv_shutdown_state = SRV_SHUTDOWN_NONE;
137
 
 
138
 
/** Files comprising the system tablespace */
 
76
#endif /* !UNIV_HOTBACKUP */
 
77
 
 
78
/* At a shutdown the value first climbs to SRV_SHUTDOWN_CLEANUP
 
79
and then to SRV_SHUTDOWN_LAST_PHASE */
 
80
UNIV_INTERN ulint               srv_shutdown_state = 0;
 
81
 
 
82
#ifndef UNIV_HOTBACKUP
139
83
static os_file_t        files[1000];
140
84
 
141
 
/** Mutex protecting the ios count */
142
85
static mutex_t          ios_mutex;
143
 
/** Count of I/O operations in io_handler_thread() */
144
86
static ulint            ios;
145
87
 
146
 
/** io_handler_thread parameters for thread identification */
147
88
static ulint            n[SRV_MAX_N_IO_THREADS + 5];
148
 
/** io_handler_thread identifiers */
149
89
static os_thread_id_t   thread_ids[SRV_MAX_N_IO_THREADS + 5];
150
90
 
151
 
/** We use this mutex to test the return value of pthread_mutex_trylock
 
91
/* We use this mutex to test the return value of pthread_mutex_trylock
152
92
   on successful locking. HP-UX does NOT return 0, though Linux et al do. */
153
93
static os_fast_mutex_t  srv_os_test_mutex;
154
94
 
155
 
/** Name of srv_monitor_file */
 
95
/* Name of srv_monitor_file */
156
96
static char*    srv_monitor_file_name;
157
97
#endif /* !UNIV_HOTBACKUP */
158
98
 
159
 
/** */
160
99
#define SRV_N_PENDING_IOS_PER_THREAD    OS_AIO_N_PENDING_IOS_PER_THREAD
161
100
#define SRV_MAX_N_PENDING_SYNC_IOS      100
162
101
 
163
102
 
164
 
/*********************************************************************//**
165
 
Convert a numeric string that optionally ends in G or M, to a number
166
 
containing megabytes.
167
 
@return next character in string */
168
103
static
169
104
char*
170
105
srv_parse_megabytes(
171
106
/*================*/
172
 
        char*   str,    /*!< in: string containing a quantity in bytes */
173
 
        ulint*  megs)   /*!< out: the number in megabytes */
 
107
                        /* out: next character in string */
 
108
        char*   str,    /* in: string containing a quantity in bytes */
 
109
        ulint*  megs)   /* out: the number in megabytes */
174
110
{
175
111
        char*   endp;
176
112
        ulint   size;
195
131
        return(str);
196
132
}
197
133
 
198
 
/*********************************************************************//**
 
134
/*************************************************************************
199
135
Reads the data files and their sizes from a character string given in
200
 
the .cnf file.
201
 
@return TRUE if ok, FALSE on parse error */
 
136
the .cnf file. */
202
137
UNIV_INTERN
203
138
ibool
204
139
srv_parse_data_file_paths_and_sizes(
205
140
/*================================*/
206
 
        char*   str)    /*!< in/out: the data file path string */
 
141
                                        /* out: TRUE if ok, FALSE if parsing
 
142
                                        error */
 
143
        char*   str,                    /* in: the data file path string */
 
144
        char*** data_file_names,        /* out, own: array of data file
 
145
                                        names */
 
146
        ulint** data_file_sizes,        /* out, own: array of data file sizes
 
147
                                        in megabytes */
 
148
        ulint** data_file_is_raw_partition,/* out, own: array of flags
 
149
                                        showing which data files are raw
 
150
                                        partitions */
 
151
        ulint*  n_data_files,           /* out: number of data files */
 
152
        ibool*  is_auto_extending,      /* out: TRUE if the last data file is
 
153
                                        auto-extending */
 
154
        ulint*  max_auto_extend_size)   /* out: max auto extend size for the
 
155
                                        last file if specified, 0 if not */
207
156
{
208
157
        char*   input_str;
209
158
        char*   path;
210
159
        ulint   size;
211
160
        ulint   i       = 0;
212
161
 
213
 
        srv_auto_extend_last_data_file = FALSE;
214
 
        srv_last_file_size_max = 0;
215
 
        srv_data_file_names = NULL;
216
 
        srv_data_file_sizes = NULL;
217
 
        srv_data_file_is_raw_partition = NULL;
 
162
        *is_auto_extending = FALSE;
 
163
        *max_auto_extend_size = 0;
218
164
 
219
165
        input_str = str;
220
166
 
291
237
                return(FALSE);
292
238
        }
293
239
 
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);
 
240
        *data_file_names = (char**)ut_malloc(i * sizeof(void*));
 
241
        *data_file_sizes = (ulint*)ut_malloc(i * sizeof(ulint));
 
242
        *data_file_is_raw_partition = (ulint*)ut_malloc(i * sizeof(ulint));
298
243
 
299
 
        srv_n_data_files = i;
 
244
        *n_data_files = i;
300
245
 
301
246
        /* Then store the actual values to our arrays */
302
247
 
326
271
 
327
272
                str = srv_parse_megabytes(str, &size);
328
273
 
329
 
                srv_data_file_names[i] = path;
330
 
                srv_data_file_sizes[i] = size;
 
274
                (*data_file_names)[i] = path;
 
275
                (*data_file_sizes)[i] = size;
331
276
 
332
277
                if (0 == strncmp(str, ":autoextend",
333
278
                                 (sizeof ":autoextend") - 1)) {
334
279
 
335
 
                        srv_auto_extend_last_data_file = TRUE;
 
280
                        *is_auto_extending = TRUE;
336
281
 
337
282
                        str += (sizeof ":autoextend") - 1;
338
283
 
342
287
                                str += (sizeof ":max:") - 1;
343
288
 
344
289
                                str = srv_parse_megabytes(
345
 
                                        str, &srv_last_file_size_max);
 
290
                                        str, max_auto_extend_size);
346
291
                        }
347
292
 
348
293
                        if (*str != '\0') {
351
296
                        }
352
297
                }
353
298
 
354
 
                (srv_data_file_is_raw_partition)[i] = 0;
 
299
                (*data_file_is_raw_partition)[i] = 0;
355
300
 
356
301
                if (strlen(str) >= 6
357
302
                    && *str == 'n'
358
303
                    && *(str + 1) == 'e'
359
304
                    && *(str + 2) == 'w') {
360
305
                        str += 3;
361
 
                        (srv_data_file_is_raw_partition)[i] = SRV_NEW_RAW;
 
306
                        (*data_file_is_raw_partition)[i] = SRV_NEW_RAW;
362
307
                }
363
308
 
364
309
                if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
365
310
                        str += 3;
366
311
 
367
 
                        if ((srv_data_file_is_raw_partition)[i] == 0) {
368
 
                                (srv_data_file_is_raw_partition)[i] = SRV_OLD_RAW;
 
312
                        if ((*data_file_is_raw_partition)[i] == 0) {
 
313
                                (*data_file_is_raw_partition)[i] = SRV_OLD_RAW;
369
314
                        }
370
315
                }
371
316
 
379
324
        return(TRUE);
380
325
}
381
326
 
382
 
/*********************************************************************//**
 
327
/*************************************************************************
383
328
Reads log group home directories from a character string given in
384
 
the .cnf file.
385
 
@return TRUE if ok, FALSE on parse error */
 
329
the .cnf file. */
386
330
UNIV_INTERN
387
331
ibool
388
332
srv_parse_log_group_home_dirs(
389
333
/*==========================*/
390
 
        char*   str)    /*!< in/out: character string */
 
334
                                        /* out: TRUE if ok, FALSE if parsing
 
335
                                        error */
 
336
        char*   str,                    /* in: character string */
 
337
        char*** log_group_home_dirs)    /* out, own: log group home dirs */
391
338
{
392
339
        char*   input_str;
393
340
        char*   path;
394
341
        ulint   i       = 0;
395
342
 
396
 
        srv_log_group_home_dirs = NULL;
397
 
 
398
343
        input_str = str;
399
344
 
400
345
        /* First calculate the number of directories and check syntax:
424
369
                return(FALSE);
425
370
        }
426
371
 
427
 
        srv_log_group_home_dirs = malloc(i * sizeof *srv_log_group_home_dirs);
 
372
        *log_group_home_dirs = (char**) ut_malloc(i * sizeof(void*));
428
373
 
429
374
        /* Then store the actual values to our array */
430
375
 
443
388
                        str++;
444
389
                }
445
390
 
446
 
                srv_log_group_home_dirs[i] = path;
 
391
                (*log_group_home_dirs)[i] = path;
447
392
 
448
393
                i++;
449
394
        }
451
396
        return(TRUE);
452
397
}
453
398
 
454
 
/*********************************************************************//**
455
 
Frees the memory allocated by srv_parse_data_file_paths_and_sizes()
456
 
and srv_parse_log_group_home_dirs(). */
457
 
UNIV_INTERN
458
 
void
459
 
srv_free_paths_and_sizes(void)
460
 
/*==========================*/
461
 
{
462
 
        free(srv_data_file_names);
463
 
        srv_data_file_names = NULL;
464
 
        free(srv_data_file_sizes);
465
 
        srv_data_file_sizes = NULL;
466
 
        free(srv_data_file_is_raw_partition);
467
 
        srv_data_file_is_raw_partition = NULL;
468
 
        free(srv_log_group_home_dirs);
469
 
        srv_log_group_home_dirs = NULL;
470
 
}
471
 
 
472
399
#ifndef UNIV_HOTBACKUP
473
 
/********************************************************************//**
474
 
I/o-handler thread function.
475
 
@return OS_THREAD_DUMMY_RETURN */
 
400
/************************************************************************
 
401
I/o-handler thread function. */
476
402
static
 
403
 
477
404
os_thread_ret_t
478
405
io_handler_thread(
479
406
/*==============*/
480
 
        void*   arg)    /*!< in: pointer to the number of the segment in
481
 
                        the aio array */
 
407
        void*   arg)
482
408
{
483
409
        ulint   segment;
484
410
        ulint   i;
501
427
        thread should always use that to exit and not use return() to exit.
502
428
        The thread actually never comes here because it is exited in an
503
429
        os_event_wait(). */
504
 
#if (!defined(__SUNPRO_C) && !defined(__SUNPRO_CC))
505
 
        return 0;
506
 
#endif
 
430
 
 
431
        os_thread_exit(NULL);
 
432
 
 
433
        OS_THREAD_DUMMY_RETURN;
507
434
}
508
435
#endif /* !UNIV_HOTBACKUP */
509
436
 
513
440
#define SRV_PATH_SEPARATOR      '/'
514
441
#endif
515
442
 
516
 
/*********************************************************************//**
 
443
/*************************************************************************
517
444
Normalizes a directory path for Windows: converts slashes to backslashes. */
518
445
UNIV_INTERN
519
446
void
520
447
srv_normalize_path_for_win(
521
448
/*=======================*/
522
 
        char*   str __attribute__((unused)))    /*!< in/out: null-terminated
 
449
        char*   str __attribute__((unused)))    /* in/out: null-terminated
523
450
                                                character string */
524
451
{
525
452
#ifdef __WIN__
532
459
#endif
533
460
}
534
461
 
535
 
/*********************************************************************//**
 
462
/*************************************************************************
536
463
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 */
 
464
and the string is not empty. */
539
465
UNIV_INTERN
540
466
char*
541
467
srv_add_path_separator_if_needed(
542
468
/*=============================*/
543
 
        char*   str)    /*!< in: null-terminated character string */
 
469
                        /* out: string which has the separator if the
 
470
                        string is not empty */
 
471
        char*   str)    /* in: null-terminated character string */
544
472
{
545
473
        char*   out_str;
546
474
        ulint   len     = ut_strlen(str);
559
487
}
560
488
 
561
489
#ifndef UNIV_HOTBACKUP
562
 
/*********************************************************************//**
 
490
/*************************************************************************
563
491
Calculates the low 32 bits when a file size which is given as a number
564
 
database pages is converted to the number of bytes.
565
 
@return low 32 bytes of file size when expressed in bytes */
 
492
database pages is converted to the number of bytes. */
566
493
static
567
494
ulint
568
495
srv_calc_low32(
569
496
/*===========*/
570
 
        ulint   file_size)      /*!< in: file size in database pages */
 
497
                                /* out: low 32 bytes of file size when
 
498
                                expressed in bytes */
 
499
        ulint   file_size)      /* in: file size in database pages */
571
500
{
572
501
        return(0xFFFFFFFFUL & (file_size << UNIV_PAGE_SIZE_SHIFT));
573
502
}
574
503
 
575
 
/*********************************************************************//**
 
504
/*************************************************************************
576
505
Calculates the high 32 bits when a file size which is given as a number
577
 
database pages is converted to the number of bytes.
578
 
@return high 32 bytes of file size when expressed in bytes */
 
506
database pages is converted to the number of bytes. */
579
507
static
580
508
ulint
581
509
srv_calc_high32(
582
510
/*============*/
583
 
        ulint   file_size)      /*!< in: file size in database pages */
 
511
                                /* out: high 32 bytes of file size when
 
512
                                expressed in bytes */
 
513
        ulint   file_size)      /* in: file size in database pages */
584
514
{
585
515
        return(file_size >> (32 - UNIV_PAGE_SIZE_SHIFT));
586
516
}
587
517
 
588
 
/*********************************************************************//**
589
 
Creates or opens the log files and closes them.
590
 
@return DB_SUCCESS or error code */
 
518
/*************************************************************************
 
519
Creates or opens the log files and closes them. */
591
520
static
592
521
ulint
593
522
open_or_create_log_file(
594
523
/*====================*/
595
 
        ibool   create_new_db,          /*!< in: TRUE if we should create a
 
524
                                        /* out: DB_SUCCESS or error code */
 
525
        ibool   create_new_db,          /* in: TRUE if we should create a
596
526
                                        new database */
597
 
        ibool*  log_file_created,       /*!< out: TRUE if new log file
 
527
        ibool*  log_file_created,       /* out: TRUE if new log file
598
528
                                        created */
599
 
        ibool   log_file_has_been_opened,/*!< in: TRUE if a log file has been
 
529
        ibool   log_file_has_been_opened,/* in: TRUE if a log file has been
600
530
                                        opened before: then it is an error
601
531
                                        to try to create another log file */
602
 
        ulint   k,                      /*!< in: log group number */
603
 
        ulint   i)                      /*!< in: log file number in group */
 
532
        ulint   k,                      /* in: log group number */
 
533
        ulint   i)                      /* in: log file number in group */
604
534
{
605
535
        ibool   ret;
606
536
        ulint   size;
738
668
        return(DB_SUCCESS);
739
669
}
740
670
 
741
 
/*********************************************************************//**
742
 
Creates or opens database data files and closes them.
743
 
@return DB_SUCCESS or error code */
 
671
/*************************************************************************
 
672
Creates or opens database data files and closes them. */
744
673
static
745
674
ulint
746
675
open_or_create_data_files(
747
676
/*======================*/
748
 
        ibool*          create_new_db,  /*!< out: TRUE if new database should be
 
677
                                        /* out: DB_SUCCESS or error code */
 
678
        ibool*          create_new_db,  /* out: TRUE if new database should be
749
679
                                        created */
750
680
#ifdef UNIV_LOG_ARCHIVE
751
 
        ulint*          min_arch_log_no,/*!< out: min of archived log
 
681
        ulint*          min_arch_log_no,/* out: min of archived log
752
682
                                        numbers in data files */
753
 
        ulint*          max_arch_log_no,/*!< out: max of archived log
 
683
        ulint*          max_arch_log_no,/* out: max of archived log
754
684
                                        numbers in data files */
755
685
#endif /* UNIV_LOG_ARCHIVE */
756
 
        ib_uint64_t*    min_flushed_lsn,/*!< out: min of flushed lsn
757
 
                                        values in data files */
758
 
        ib_uint64_t*    max_flushed_lsn,/*!< out: max of flushed lsn
759
 
                                        values in data files */
760
 
        ulint*          sum_of_new_sizes)/*!< out: sum of sizes of the
 
686
        ib_uint64_t*    min_flushed_lsn,/* out: min of flushed lsn
 
687
                                        values in data files */
 
688
        ib_uint64_t*    max_flushed_lsn,/* out: max of flushed lsn
 
689
                                        values in data files */
 
690
        ulint*          sum_of_new_sizes)/* out: sum of sizes of the
761
691
                                        new files added */
762
692
{
763
693
        ibool   ret;
1010
940
        return(DB_SUCCESS);
1011
941
}
1012
942
 
1013
 
/****************************************************************//**
 
943
/********************************************************************
1014
944
Starts InnoDB and creates a new database if database files
1015
 
are not found and the user wants.
1016
 
@return DB_SUCCESS or error code */
 
945
are not found and the user wants. Server parameters are
 
946
read from a file of name "srv_init" in the ib_home directory. */
1017
947
UNIV_INTERN
1018
948
int
1019
949
innobase_start_or_create_for_mysql(void)
1020
950
/*====================================*/
 
951
                                /* out: DB_SUCCESS or error code */
1021
952
{
1022
953
        buf_pool_t*     ret;
1023
954
        ibool           create_new_db;
1035
966
        ulint           tablespace_size_in_header;
1036
967
        ulint           err;
1037
968
        ulint           i;
1038
 
        ulint           io_limit;
1039
969
        my_bool         srv_file_per_table_original_value
1040
970
                = srv_file_per_table;
1041
971
        mtr_t           mtr;
1103
1033
                "InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n");
1104
1034
#endif
1105
1035
 
1106
 
        if (UNIV_LIKELY(srv_use_sys_malloc)) {
1107
 
                fprintf(stderr,
1108
 
                        "InnoDB: The InnoDB memory heap is disabled\n");
1109
 
        }
1110
 
 
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 */
1139
 
 
1140
1036
        /* Since InnoDB does not currently clean up all its internal data
1141
1037
        structures in MySQL Embedded Server Library server_end(), we
1142
1038
        print an error message if someone tries to start up InnoDB a
1164
1060
        os_aio_use_native_aio = FALSE;
1165
1061
 
1166
1062
#ifdef __WIN__
1167
 
        switch (os_get_os_version()) {
1168
 
        case OS_WIN95:
1169
 
        case OS_WIN31:
1170
 
        case OS_WINNT:
 
1063
        if (os_get_os_version() == OS_WIN95
 
1064
            || os_get_os_version() == OS_WIN31
 
1065
            || os_get_os_version() == OS_WINNT) {
 
1066
 
1171
1067
                /* On Win 95, 98, ME, Win32 subsystem for Windows 3.1,
1172
1068
                and NT use simulated aio. In NT Windows provides async i/o,
1173
1069
                but when run in conjunction with InnoDB Hot Backup, it seemed
1174
1070
                to corrupt the data files. */
1175
1071
 
1176
1072
                os_aio_use_native_aio = FALSE;
1177
 
                break;
1178
 
        default:
 
1073
        } else {
1179
1074
                /* On Win 2000 and XP use async i/o */
1180
1075
                os_aio_use_native_aio = TRUE;
1181
 
                break;
1182
1076
        }
1183
1077
#endif
1184
1078
        if (srv_file_flush_method_str == NULL) {
1296
1190
                return(DB_ERROR);
1297
1191
        }
1298
1192
 
1299
 
        /* If user has set the value of innodb_file_io_threads then
1300
 
        we'll emit a message telling the user that this parameter
1301
 
        is now deprecated. */
1302
 
        if (srv_n_file_io_threads != 4) {
1303
 
                fprintf(stderr, "InnoDB: Warning:"
1304
 
                        " innodb_file_io_threads is deprecated."
1305
 
                        " Please use innodb_read_io_threads and"
1306
 
                        " innodb_write_io_threads instead\n");
 
1193
        /* Restrict the maximum number of file i/o threads */
 
1194
        if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
 
1195
 
 
1196
                srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
1307
1197
        }
1308
1198
 
1309
 
        /* Now overwrite the value on srv_n_file_io_threads */
1310
 
        srv_n_file_io_threads = 2 + srv_n_read_io_threads
1311
 
                                + srv_n_write_io_threads;
1312
 
 
1313
 
        ut_a(srv_n_file_io_threads <= SRV_MAX_N_IO_THREADS);
1314
 
 
1315
 
        /* TODO: Investigate if SRV_N_PENDING_IOS_PER_THREAD (32) limit
1316
 
        still applies to windows. */
1317
1199
        if (!os_aio_use_native_aio) {
1318
 
                io_limit = 8 * SRV_N_PENDING_IOS_PER_THREAD;
 
1200
                /* In simulated aio we currently have use only for 4 threads */
 
1201
                srv_n_file_io_threads = 4;
 
1202
 
 
1203
                os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
 
1204
                            * srv_n_file_io_threads,
 
1205
                            srv_n_file_io_threads,
 
1206
                            SRV_MAX_N_PENDING_SYNC_IOS);
1319
1207
        } else {
1320
 
                io_limit = SRV_N_PENDING_IOS_PER_THREAD;
 
1208
                os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
 
1209
                            * srv_n_file_io_threads,
 
1210
                            srv_n_file_io_threads,
 
1211
                            SRV_MAX_N_PENDING_SYNC_IOS);
1321
1212
        }
1322
1213
 
1323
 
        os_aio_init(io_limit,
1324
 
                    srv_n_read_io_threads,
1325
 
                    srv_n_write_io_threads,
1326
 
                    SRV_MAX_N_PENDING_SYNC_IOS);
1327
 
 
1328
 
        fil_init(srv_file_per_table ? 50000 : 5000,
1329
 
                 srv_max_n_open_files);
 
1214
        fil_init(srv_max_n_open_files);
1330
1215
 
1331
1216
        ret = buf_pool_init();
1332
1217
 
1871
1756
                        " to an earlier version of\n"
1872
1757
                        "InnoDB: InnoDB! But if you absolutely need to"
1873
1758
                        " downgrade, see\n"
1874
 
                        "InnoDB: " REFMAN "multiple-tablespaces.html\n"
 
1759
                        "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
 
1760
                        "multiple-tablespaces.html\n"
1875
1761
                        "InnoDB: for instructions.\n");
1876
1762
        }
1877
1763
 
1891
1777
        return((int) DB_SUCCESS);
1892
1778
}
1893
1779
 
1894
 
/****************************************************************//**
1895
 
Shuts down the InnoDB database.
1896
 
@return DB_SUCCESS or error code */
 
1780
/********************************************************************
 
1781
Shuts down the InnoDB database. */
1897
1782
UNIV_INTERN
1898
1783
int
1899
1784
innobase_shutdown_for_mysql(void)
1900
1785
/*=============================*/
 
1786
                                /* out: DB_SUCCESS or error code */
1901
1787
{
1902
1788
        ulint   i;
1903
1789
#ifdef __NETWARE__
1932
1818
        }
1933
1819
 
1934
1820
#ifdef __NETWARE__
1935
 
        if (!panic_shutdown)
 
1821
        if(!panic_shutdown)
1936
1822
#endif
1937
1823
                logs_empty_and_mark_files_at_shutdown();
1938
1824