57
57
#include "que0que.h"
59
59
/* Log sequence number immediately after startup */
60
UNIV_INTERN ib_uint64_t srv_start_lsn;
61
61
/* Log sequence number at shutdown */
62
dulint srv_shutdown_lsn;
62
UNIV_INTERN ib_uint64_t srv_shutdown_lsn;
64
64
#ifdef HAVE_DARWIN_THREADS
65
65
# include <sys/utsname.h>
66
ibool srv_have_fullfsync = FALSE;
66
UNIV_INTERN ibool srv_have_fullfsync = FALSE;
69
ibool srv_start_raw_disk_in_use = FALSE;
71
ulint srv_sizeof_trx_t_in_ha_innodb_cc;
73
ibool srv_startup_is_before_trx_rollback_phase = FALSE;
74
ibool srv_is_being_started = FALSE;
69
UNIV_INTERN ibool srv_start_raw_disk_in_use = FALSE;
71
UNIV_INTERN ibool srv_startup_is_before_trx_rollback_phase = FALSE;
72
UNIV_INTERN ibool srv_is_being_started = FALSE;
73
UNIV_INTERN ibool srv_was_started = FALSE;
75
74
#ifndef UNIV_HOTBACKUP
76
75
static ibool srv_start_has_been_called = FALSE;
77
static ibool srv_was_started = FALSE;
78
76
#endif /* !UNIV_HOTBACKUP */
80
78
/* At a shutdown the value first climbs to SRV_SHUTDOWN_CLEANUP
81
79
and then to SRV_SHUTDOWN_LAST_PHASE */
82
ulint srv_shutdown_state = 0;
80
UNIV_INTERN ulint srv_shutdown_state = 0;
84
82
#ifndef UNIV_HOTBACKUP
85
83
static os_file_t files[1000];
150
148
/*************************************************************************
151
149
Reads the data files and their sizes from a character string given in
152
150
the .cnf file. */
155
153
srv_parse_data_file_paths_and_sizes(
156
154
/*================================*/
458
456
/*************************************************************************
459
457
Normalizes a directory path for Windows: converts slashes to backslashes. */
462
460
srv_normalize_path_for_win(
463
461
/*=======================*/
477
475
/*************************************************************************
478
476
Adds a slash or a backslash to the end of a string if it is missing
479
477
and the string is not empty. */
482
480
srv_add_path_separator_if_needed(
483
481
/*=============================*/
652
650
which is for this log group */
654
652
fil_space_create(name,
655
2 * k + SRV_LOG_SPACE_FIRST_ID, FIL_LOG);
653
2 * k + SRV_LOG_SPACE_FIRST_ID, 0, FIL_LOG);
658
656
ut_a(fil_validate());
667
665
if (k == 0 && i == 0) {
668
666
arch_space_id = 2 * k + 1 + SRV_LOG_SPACE_FIRST_ID;
670
fil_space_create("arch_log_space", arch_space_id, FIL_LOG);
668
fil_space_create("arch_log_space", arch_space_id, 0, FIL_LOG);
672
670
arch_space_id = ULINT_UNDEFINED;
690
688
open_or_create_data_files(
691
689
/*======================*/
692
/* out: DB_SUCCESS or error code */
693
ibool* create_new_db, /* out: TRUE if new database should be
690
/* out: DB_SUCCESS or error code */
691
ibool* create_new_db, /* out: TRUE if new database should be
695
693
#ifdef UNIV_LOG_ARCHIVE
696
ulint* min_arch_log_no,/* out: min of archived log numbers in data
698
ulint* max_arch_log_no,/* out: */
694
ulint* min_arch_log_no,/* out: min of archived log
695
numbers in data files */
696
ulint* max_arch_log_no,/* out: max of archived log
697
numbers in data files */
699
698
#endif /* UNIV_LOG_ARCHIVE */
700
dulint* min_flushed_lsn,/* out: min of flushed lsn values in data
702
dulint* max_flushed_lsn,/* out: */
703
ulint* sum_of_new_sizes)/* out: sum of sizes of the new files added */
699
ib_uint64_t* min_flushed_lsn,/* out: min of flushed lsn
700
values in data files */
701
ib_uint64_t* max_flushed_lsn,/* out: max of flushed lsn
702
values in data files */
703
ulint* sum_of_new_sizes)/* out: sum of sizes of the
939
fil_space_create(name, 0, FIL_TABLESPACE);
940
fil_space_create(name, 0, 0, FIL_TABLESPACE);
942
943
ut_a(fil_validate());
944
if (srv_data_file_is_raw_partition[i]) {
946
fil_node_create(name, srv_data_file_sizes[i], 0, TRUE);
948
fil_node_create(name, srv_data_file_sizes[i], 0,
945
fil_node_create(name, srv_data_file_sizes[i], 0,
946
srv_data_file_is_raw_partition[i] != 0);
961
957
Starts InnoDB and creates a new database if database files
962
958
are not found and the user wants. Server parameters are
963
959
read from a file of name "srv_init" in the ib_home directory. */
966
962
innobase_start_or_create_for_mysql(void)
967
963
/*====================================*/
968
964
/* out: DB_SUCCESS or error code */
972
ibool log_file_created;
973
ibool log_created = FALSE;
974
ibool log_opened = FALSE;
975
dulint min_flushed_lsn;
976
dulint max_flushed_lsn;
968
ibool log_file_created;
969
ibool log_created = FALSE;
970
ibool log_opened = FALSE;
971
ib_uint64_t min_flushed_lsn;
972
ib_uint64_t max_flushed_lsn;
977
973
#ifdef UNIV_LOG_ARCHIVE
978
ulint min_arch_log_no;
979
ulint max_arch_log_no;
974
ulint min_arch_log_no;
975
ulint max_arch_log_no;
980
976
#endif /* UNIV_LOG_ARCHIVE */
981
ulint sum_of_new_sizes;
982
ulint sum_of_data_file_sizes;
983
ulint tablespace_size_in_header;
986
ibool srv_file_per_table_original_value = srv_file_per_table;
977
ulint sum_of_new_sizes;
978
ulint sum_of_data_file_sizes;
979
ulint tablespace_size_in_header;
982
my_bool srv_file_per_table_original_value
983
= srv_file_per_table;
988
985
#ifdef HAVE_DARWIN_THREADS
989
986
# ifdef F_FULLFSYNC
990
987
/* This executable has been compiled on Mac OS X 10.3 or later.
1018
1015
(ulong)sizeof(ulint), (ulong)sizeof(void*));
1021
srv_file_per_table = FALSE; /* system tables are created in tablespace
1018
/* System tables are created in tablespace 0. Thus, we must
1019
temporarily clear srv_file_per_table. This is ok, because the
1020
server will not accept connections (which could modify
1021
innodb_file_per_table) until this function has returned. */
1022
srv_file_per_table = FALSE;
1023
1023
#ifdef UNIV_DEBUG
1024
1024
fprintf(stderr,
1025
1025
"InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!\n");
1046
1046
"InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n");
1049
#ifdef UNIV_SIMULATE_AWE
1051
"InnoDB: !!!!!!!! UNIV_SIMULATE_AWE switched on !!!!!!!!!\n");
1053
if (srv_sizeof_trx_t_in_ha_innodb_cc != (ulint)sizeof(trx_t)) {
1055
"InnoDB: Error: trx_t size is %lu in ha_innodb.cc"
1056
" but %lu in srv0start.c\n"
1057
"InnoDB: Check that pthread_mutex_t is defined"
1058
" in the same way in these\n"
1059
"InnoDB: compilation modules. Cannot continue.\n",
1060
(ulong) srv_sizeof_trx_t_in_ha_innodb_cc,
1061
(ulong) sizeof(trx_t));
1065
1049
/* Since InnoDB does not currently clean up all its internal data
1066
1050
structures in MySQL Embedded Server Library server_end(), we
1067
1051
print an error message if someone tries to start up InnoDB a
1088
1072
srv_startup_is_before_trx_rollback_phase = TRUE;
1089
1073
os_aio_use_native_aio = FALSE;
1091
#if !defined(__WIN2000__) && !defined(UNIV_SIMULATE_AWE)
1095
"InnoDB: Error: You have specified"
1096
" innodb_buffer_pool_awe_mem_mb\n"
1097
"InnoDB: in my.cnf, but AWE can only"
1098
" be used in Windows 2000 and later.\n"
1099
"InnoDB: To use AWE, InnoDB must"
1100
" be compiled with __WIN2000__ defined.\n");
1107
1076
if (os_get_os_version() == OS_WIN95
1108
1077
|| os_get_os_version() == OS_WIN31
1164
1133
/* Note that the call srv_boot() also changes the values of
1165
srv_pool_size etc. to the units used by InnoDB internally */
1134
some variables to the units used by InnoDB internally */
1167
1136
/* Set the maximum number of threads which can wait for a semaphore
1168
1137
inside InnoDB: this is the 'sync wait array' size, as well as the
1169
1138
maximum number of threads that can wait in the 'srv_conc array' for
1170
1139
their time to enter InnoDB. */
1172
if (srv_pool_size >= 1000 * 1024) {
1173
/* Here we still have srv_pool_size counted
1174
in kilobytes (in 4.0 this was in bytes)
1175
srv_boot() converts the value to
1176
pages; if buffer pool is less than 1000 MB,
1141
#if defined(__NETWARE__)
1143
/* Create less event semaphores because Win 98/ME had
1144
difficulty creating 40000 event semaphores. Comment from
1145
Novell, Inc.: also, these just take a lot of memory on
1147
srv_max_n_threads = 1000;
1149
if (srv_buf_pool_size >= 1000 * 1024 * 1024) {
1150
/* If buffer pool is less than 1000 MB,
1177
1151
assume fewer threads. */
1178
1152
srv_max_n_threads = 50000;
1180
} else if (srv_pool_size >= 8 * 1024) {
1154
} else if (srv_buf_pool_size >= 8 * 1024 * 1024) {
1182
1156
srv_max_n_threads = 10000;
1252
1227
fil_init(srv_max_n_open_files);
1256
"InnoDB: Using AWE: Memory window is %lu MB"
1257
" and AWE memory is %lu MB\n",
1258
(ulong) (srv_awe_window_size / ((1024 * 1024)
1260
(ulong) (srv_pool_size / ((1024 * 1024)
1261
/ UNIV_PAGE_SIZE)));
1263
/* We must disable adaptive hash indexes because they do not
1264
tolerate remapping of pages in AWE */
1266
srv_use_adaptive_hash_indexes = FALSE;
1267
ret = buf_pool_init(srv_pool_size, srv_pool_size,
1268
srv_awe_window_size);
1270
ret = buf_pool_init(srv_pool_size, srv_pool_size,
1229
ret = buf_pool_init();
1274
1231
if (ret == NULL) {
1275
1232
fprintf(stderr,
1408
1365
&& !srv_archive_recovery
1409
1366
#endif /* UNIV_LOG_ARCHIVE */
1411
if (ut_dulint_cmp(max_flushed_lsn, min_flushed_lsn) != 0
1368
if (max_flushed_lsn != min_flushed_lsn
1412
1369
#ifdef UNIV_LOG_ARCHIVE
1413
1370
|| max_arch_log_no != min_arch_log_no
1414
1371
#endif /* UNIV_LOG_ARCHIVE */
1485
1442
/* Initialize the fsp free limit global variable in the log
1487
fsp_header_get_free_limit(0);
1444
fsp_header_get_free_limit();
1489
1446
recv_recovery_from_archive_finish();
1490
1447
#endif /* UNIV_LOG_ARCHIVE */
1450
/* Check if we support the max format that is stamped
1451
on the system tablespace. */
1452
err = trx_sys_file_format_max_check(
1453
srv_check_file_format_at_startup);
1455
if (err != DB_SUCCESS) {
1492
1459
/* We always try to do a recovery, even if the database had
1493
1460
been shut down normally: this is the normal startup path */
1495
1462
err = recv_recovery_from_checkpoint_start(LOG_CHECKPOINT,
1497
1464
min_flushed_lsn,
1498
1465
max_flushed_lsn);
1499
1466
if (err != DB_SUCCESS) {
1540
1507
/* Initialize the fsp free limit global variable in the log
1542
fsp_header_get_free_limit(0);
1509
fsp_header_get_free_limit();
1544
1511
/* recv_recovery_from_checkpoint_finish needs trx lists which
1545
1512
are initialized in trx_sys_init_at_db_start(). */
1595
1562
/* Create the thread which warns of long semaphore waits */
1596
1563
os_thread_create(&srv_error_monitor_thread, NULL,
1597
1564
thread_ids + 3 + SRV_MAX_N_IO_THREADS);
1598
srv_was_started = TRUE;
1599
1565
srv_is_being_started = FALSE;
1601
1567
if (trx_doublewrite == NULL) {
1624
1590
sum_of_data_file_sizes += srv_data_file_sizes[i];
1627
tablespace_size_in_header = fsp_header_get_tablespace_size(0);
1593
tablespace_size_in_header = fsp_header_get_tablespace_size();
1629
1595
if (!srv_auto_extend_last_data_file
1630
1596
&& sum_of_data_file_sizes != tablespace_size_in_header) {
1708
1674
if (srv_print_verbose_log) {
1709
1675
ut_print_timestamp(stderr);
1710
1676
fprintf(stderr,
1711
" InnoDB: Started; log sequence number %lu %lu\n",
1712
(ulong) ut_dulint_get_high(srv_start_lsn),
1713
(ulong) ut_dulint_get_low(srv_start_lsn));
1677
" InnoDB Plugin %s started; "
1678
"log sequence number %"PRIu64"\n",
1679
INNODB_VERSION_STR, srv_start_lsn);
1716
1682
if (srv_force_recovery > 0) {
1783
1749
srv_file_per_table = srv_file_per_table_original_value;
1751
srv_was_started = TRUE;
1785
1753
return((int) DB_SUCCESS);
1788
1756
/********************************************************************
1789
1757
Shuts down the InnoDB database. */
1792
1760
innobase_shutdown_for_mysql(void)
1793
1761
/*=============================*/
1794
1762
/* out: DB_SUCCESS or error code */
1766
extern ibool panic_shutdown;
1797
1768
if (!srv_was_started) {
1798
1769
if (srv_is_being_started) {
1799
1770
ut_print_timestamp(stderr);
1964
1941
ut_print_timestamp(stderr);
1965
1942
fprintf(stderr,
1966
1943
" InnoDB: Shutdown completed;"
1967
" log sequence number %lu %lu\n",
1968
(ulong) ut_dulint_get_high(srv_shutdown_lsn),
1969
(ulong) ut_dulint_get_low(srv_shutdown_lsn));
1944
" log sequence number %"PRIu64"\n",
1948
srv_was_started = FALSE;
1972
1950
return((int) DB_SUCCESS);
1954
void set_panic_flag_for_netware()
1956
extern ibool panic_shutdown;
1957
panic_shutdown = TRUE;
1959
#endif /* __NETWARE__ */
1975
1960
#endif /* !UNIV_HOTBACKUP */