1
1
/*****************************************************************************
3
Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
4
4
Copyright (c) 2008, Google Inc.
5
Copyright (c) 2009, Percona Inc.
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.
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
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.
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
32
24
*****************************************************************************/
25
/***********************************************************************
27
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
28
Copyright (c) 2009, Percona Inc.
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
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.
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.
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
50
***********************************************************************/
34
52
/********************************************************************//**
35
53
@file srv/srv0start.c
129
144
static ulint ios;
131
146
/** io_handler_thread parameters for thread identification */
132
static ulint n[SRV_MAX_N_IO_THREADS + 6];
147
static ulint n[SRV_MAX_N_IO_THREADS + 5];
133
148
/** io_handler_thread identifiers */
134
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6];
149
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 5];
136
151
/** We use this mutex to test the return value of pthread_mutex_trylock
137
152
on successful locking. HP-UX does NOT return 0, though Linux et al do. */
145
160
#define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD
146
161
#define SRV_MAX_N_PENDING_SYNC_IOS 100
148
#ifdef UNIV_PFS_THREAD
149
/* Keys to register InnoDB threads with performance schema */
150
UNIV_INTERN mysql_pfs_key_t io_handler_thread_key;
151
UNIV_INTERN mysql_pfs_key_t srv_lock_timeout_thread_key;
152
UNIV_INTERN mysql_pfs_key_t srv_error_monitor_thread_key;
153
UNIV_INTERN mysql_pfs_key_t srv_monitor_thread_key;
154
UNIV_INTERN mysql_pfs_key_t srv_master_thread_key;
155
#endif /* UNIV_PFS_THREAD */
157
#ifdef UNIV_PFS_MUTEX
158
/* Key to register ios_mutex_key with performance schema */
159
UNIV_INTERN mysql_pfs_key_t ios_mutex_key;
160
#endif /* UNIV_PFS_MUTEX */
162
164
/*********************************************************************//**
163
165
Convert a numeric string that optionally ends in G or M, to a number
486
489
fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,
487
490
os_thread_pf(os_thread_get_curr_id()));
490
#ifdef UNIV_PFS_THREAD
491
pfs_register_thread(io_handler_thread_key);
492
#endif /* UNIV_PFS_THREAD */
494
while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) {
495
493
fil_aio_wait(segment);
497
495
mutex_enter(&ios_mutex);
499
497
mutex_exit(&ios_mutex);
502
thr_local_free(os_thread_get_curr_id());
504
500
/* We count the number of threads in os_thread_exit(). A created
505
501
thread should always use that to exit and not use return() to exit.
506
502
The thread actually never comes here because it is exited in an
507
503
os_event_wait(). */
504
#if (!defined(__SUNPRO_C) && !defined(__SUNPRO_CC))
510
508
#endif /* !UNIV_HOTBACKUP */
535
/*********************************************************************//**
536
Adds a slash or a backslash to the end of a string if it is missing
537
and the string is not empty.
538
@return string which has the separator if the string is not empty */
541
srv_add_path_separator_if_needed(
542
/*=============================*/
543
char* str) /*!< in: null-terminated character string */
546
ulint len = ut_strlen(str);
548
if (len == 0 || str[len - 1] == SRV_PATH_SEPARATOR) {
553
out_str = ut_malloc(len + 2);
554
memcpy(out_str, str, len);
555
out_str[len] = SRV_PATH_SEPARATOR;
556
out_str[len + 1] = 0;
537
561
#ifndef UNIV_HOTBACKUP
538
562
/*********************************************************************//**
539
563
Calculates the low 32 bits when a file size which is given as a number
584
608
char name[10000];
587
610
UT_NOT_USED(create_new_db);
589
612
*log_file_created = FALSE;
591
614
srv_normalize_path_for_win(srv_log_group_home_dirs[k]);
593
dirnamelen = strlen(srv_log_group_home_dirs[k]);
594
ut_a(dirnamelen < (sizeof name) - 10 - sizeof "ib_logfile");
595
memcpy(name, srv_log_group_home_dirs[k], dirnamelen);
597
/* Add a path separator if needed. */
598
if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
599
name[dirnamelen++] = SRV_PATH_SEPARATOR;
602
sprintf(name + dirnamelen, "%s%lu", "ib_logfile", (ulong) i);
604
files[i] = os_file_create(innodb_file_log_key, name,
605
OS_FILE_CREATE, OS_FILE_NORMAL,
615
srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed(
616
srv_log_group_home_dirs[k]);
618
ut_a(strlen(srv_log_group_home_dirs[k])
619
< (sizeof name) - 10 - sizeof "ib_logfile");
620
sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k],
621
"ib_logfile", (ulong) i);
623
files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL,
606
624
OS_LOG_FILE, &ret);
607
625
if (ret == FALSE) {
608
626
if (os_file_get_last_error(FALSE) != OS_FILE_ALREADY_EXISTS
620
638
return(DB_ERROR);
623
files[i] = os_file_create(innodb_file_log_key, name,
624
OS_FILE_OPEN, OS_FILE_AIO,
641
files[i] = os_file_create(name, OS_FILE_OPEN, OS_FILE_AIO,
625
642
OS_LOG_FILE, &ret);
764
781
*create_new_db = FALSE;
766
783
srv_normalize_path_for_win(srv_data_home);
784
srv_data_home = srv_add_path_separator_if_needed(srv_data_home);
768
786
for (i = 0; i < srv_n_data_files; i++) {
771
787
srv_normalize_path_for_win(srv_data_file_names[i]);
772
dirnamelen = strlen(srv_data_home);
774
ut_a(dirnamelen + strlen(srv_data_file_names[i])
789
ut_a(strlen(srv_data_home) + strlen(srv_data_file_names[i])
775
790
< (sizeof name) - 1);
776
memcpy(name, srv_data_home, dirnamelen);
777
/* Add a path separator if needed. */
778
if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
779
name[dirnamelen++] = SRV_PATH_SEPARATOR;
782
strcpy(name + dirnamelen, srv_data_file_names[i]);
791
sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]);
784
793
if (srv_data_file_is_raw_partition[i] == 0) {
786
795
/* First we try to create the file: if it already
787
796
exists, ret will get value FALSE */
789
files[i] = os_file_create(innodb_file_data_key,
790
name, OS_FILE_CREATE,
798
files[i] = os_file_create(name, OS_FILE_CREATE,
792
800
OS_DATA_FILE, &ret);
814
822
srv_start_raw_disk_in_use = TRUE;
815
823
srv_created_new_raw = TRUE;
817
files[i] = os_file_create(innodb_file_data_key,
818
name, OS_FILE_OPEN_RAW,
825
files[i] = os_file_create(name, OS_FILE_OPEN_RAW,
820
827
OS_DATA_FILE, &ret);
849
856
if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
850
857
files[i] = os_file_create(
851
innodb_file_data_key,
852
858
name, OS_FILE_OPEN_RAW,
853
859
OS_FILE_NORMAL, OS_DATA_FILE, &ret);
854
860
} else if (i == 0) {
855
861
files[i] = os_file_create(
856
innodb_file_data_key,
857
862
name, OS_FILE_OPEN_RETRY,
858
863
OS_FILE_NORMAL, OS_DATA_FILE, &ret);
860
865
files[i] = os_file_create(
861
innodb_file_data_key,
862
866
name, OS_FILE_OPEN, OS_FILE_NORMAL,
863
867
OS_DATA_FILE, &ret);
1004
mutex_create(ios_mutex_key, &ios_mutex, SYNC_NO_ORDER_CHECK);
1008
mutex_create(&ios_mutex, SYNC_NO_ORDER_CHECK);
1006
1010
return(DB_SUCCESS);
1009
/********************************************************************
1013
/****************************************************************//**
1010
1014
Starts InnoDB and creates a new database if database files
1011
1015
are not found and the user wants.
1012
1016
@return DB_SUCCESS or error code */
1080
1085
#ifdef UNIV_IBUF_DEBUG
1081
1086
fprintf(stderr,
1082
1087
"InnoDB: !!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!\n"
1083
# ifdef UNIV_IBUF_COUNT_DEBUG
1084
"InnoDB: !!!!!!!! UNIV_IBUF_COUNT_DEBUG switched on !!!!!!!!!\n"
1085
"InnoDB: Crash recovery will fail with UNIV_IBUF_COUNT_DEBUG\n"
1088
"InnoDB: Crash recovery will fail with UNIV_IBUF_DEBUG\n");
1090
1091
#ifdef UNIV_SYNC_DEBUG
1097
1098
"InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n");
1100
#ifdef UNIV_LOG_LSN_DEBUG
1102
"InnoDB: !!!!!!!! UNIV_LOG_LSN_DEBUG switched on !!!!!!!!!\n");
1103
#endif /* UNIV_LOG_LSN_DEBUG */
1104
1101
#ifdef UNIV_MEM_DEBUG
1105
1102
fprintf(stderr,
1106
1103
"InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n");
1111
1108
"InnoDB: The InnoDB memory heap is disabled\n");
1114
fputs("InnoDB: " IB_ATOMICS_STARTUP_MSG
1115
"\nInnoDB: Compressed tables use zlib " ZLIB_VERSION
1116
#ifdef UNIV_ZIP_DEBUG
1118
#endif /* UNIV_ZIP_DEBUG */
1119
#ifdef UNIV_ZIP_COPY
1120
" and extra copying"
1121
#endif /* UNIV_ZIP_COPY */
1111
#ifdef HAVE_GCC_ATOMIC_BUILTINS
1112
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1114
"InnoDB: Mutexes and rw_locks use GCC atomic builtins.\n");
1115
# else /* INNODB_RW_LOCKS_USE_ATOMICS */
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
1122
"InnoDB: Mutexes and rw_locks use Solaris atomic functions.\n");
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
1130
"InnoDB: Mutexes and rw_locks use Windows interlocked functions.\n");
1133
"InnoDB: Mutexes use Windows interlocked functions.\n");
1134
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1135
#else /* HAVE_GCC_ATOMIC_BUILTINS */
1137
"InnoDB: Neither mutexes nor rw_locks use GCC atomic builtins.\n");
1138
#endif /* HAVE_GCC_ATOMIC_BUILTINS */
1125
1140
/* Since InnoDB does not currently clean up all its internal data
1126
1141
structures in MySQL Embedded Server Library server_end(), we
1130
1145
if (srv_start_has_been_called) {
1131
1146
fprintf(stderr,
1132
"InnoDB: Error: startup called second time"
1147
"InnoDB: Error:startup called second time"
1133
1148
" during the process lifetime.\n"
1134
1149
"InnoDB: In the MySQL Embedded Server Library"
1135
1150
" you cannot call server_init()\n"
1157
1173
but when run in conjunction with InnoDB Hot Backup, it seemed
1158
1174
to corrupt the data files. */
1160
srv_use_native_aio = FALSE;
1165
/* On 2000 and XP, async IO is available. */
1166
srv_use_native_aio = TRUE;
1176
os_aio_use_native_aio = FALSE;
1170
/* Vista and later have both async IO and condition variables */
1171
srv_use_native_aio = TRUE;
1172
srv_use_native_conditions = TRUE;
1179
/* On Win 2000 and XP use async i/o */
1180
os_aio_use_native_aio = TRUE;
1176
#elif defined(LINUX_NATIVE_AIO)
1178
if (srv_use_native_aio) {
1179
ut_print_timestamp(stderr);
1181
" InnoDB: Using Linux native AIO\n");
1184
/* Currently native AIO is supported only on windows and linux
1185
and that also when the support is compiled in. In all other
1186
cases, we ignore the setting of innodb_use_native_aio. */
1187
srv_use_native_aio = FALSE;
1191
1184
if (srv_file_flush_method_str == NULL) {
1192
1185
/* These are the default options */
1213
1206
} else if (0 == ut_strcmp(srv_file_flush_method_str, "normal")) {
1214
1207
srv_win_file_flush_method = SRV_WIN_IO_NORMAL;
1215
srv_use_native_aio = FALSE;
1208
os_aio_use_native_aio = FALSE;
1217
1210
} else if (0 == ut_strcmp(srv_file_flush_method_str, "unbuffered")) {
1218
1211
srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
1219
srv_use_native_aio = FALSE;
1212
os_aio_use_native_aio = FALSE;
1221
1214
} else if (0 == ut_strcmp(srv_file_flush_method_str,
1222
1215
"async_unbuffered")) {
1238
1231
maximum number of threads that can wait in the 'srv_conc array' for
1239
1232
their time to enter InnoDB. */
1234
#if defined(__NETWARE__)
1236
/* Create less event semaphores because Win 98/ME had
1237
difficulty creating 40000 event semaphores. Comment from
1238
Novell, Inc.: also, these just take a lot of memory on
1240
srv_max_n_threads = 1000;
1241
1242
if (srv_buf_pool_size >= 1000 * 1024 * 1024) {
1242
1243
/* If buffer pool is less than 1000 MB,
1243
assume fewer threads. Also use only one
1244
buffer pool instance */
1244
assume fewer threads. */
1245
1245
srv_max_n_threads = 50000;
1247
1247
} else if (srv_buf_pool_size >= 8 * 1024 * 1024) {
1249
srv_buf_pool_instances = 1;
1250
1249
srv_max_n_threads = 10000;
1252
srv_buf_pool_instances = 1;
1253
1251
srv_max_n_threads = 1000; /* saves several MB of memory,
1254
1252
especially in 64-bit
1258
1256
err = srv_boot();
1260
1258
if (err != DB_SUCCESS) {
1262
1260
return((int) err);
1265
mutex_create(srv_monitor_file_mutex_key,
1266
&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
1263
mutex_create(&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
1268
1265
if (srv_innodb_status) {
1269
1266
srv_monitor_file_name = mem_alloc(
1288
mutex_create(srv_dict_tmpfile_mutex_key,
1289
&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1285
mutex_create(&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1291
1287
srv_dict_tmpfile = os_file_create_tmpfile();
1292
1288
if (!srv_dict_tmpfile) {
1293
1289
return(DB_ERROR);
1296
mutex_create(srv_misc_tmpfile_mutex_key,
1297
&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1292
mutex_create(&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1299
1294
srv_misc_tmpfile = os_file_create_tmpfile();
1300
1295
if (!srv_misc_tmpfile) {
1301
1296
return(DB_ERROR);
1304
/* innodb_file_io_threads used to be user settable.
1305
It is now just a combination of read_io_threads and
1306
write_io_threads that is set by innodb internally. */
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");
1308
1309
/* Now overwrite the value on srv_n_file_io_threads */
1309
1310
srv_n_file_io_threads = 2 + srv_n_read_io_threads
1314
1315
/* TODO: Investigate if SRV_N_PENDING_IOS_PER_THREAD (32) limit
1315
1316
still applies to windows. */
1316
if (!srv_use_native_aio) {
1317
if (!os_aio_use_native_aio) {
1317
1318
io_limit = 8 * SRV_N_PENDING_IOS_PER_THREAD;
1319
1320
io_limit = SRV_N_PENDING_IOS_PER_THREAD;
1327
1328
fil_init(srv_file_per_table ? 50000 : 5000,
1328
1329
srv_max_n_open_files);
1330
/* Print time to initialize the buffer pool */
1331
ut_print_timestamp(stderr);
1333
" InnoDB: Initializing buffer pool, size =");
1335
if (srv_buf_pool_size >= 1024 * 1024 * 1024) {
1338
((double) srv_buf_pool_size) / (1024 * 1024 * 1024));
1342
((double) srv_buf_pool_size) / (1024 * 1024));
1345
err = buf_pool_init(srv_buf_pool_size, srv_buf_pool_instances);
1347
ut_print_timestamp(stderr);
1349
" InnoDB: Completed initialization of buffer pool\n");
1351
if (err != DB_SUCCESS) {
1331
ret = buf_pool_init();
1352
1334
fprintf(stderr,
1353
1335
"InnoDB: Fatal error: cannot allocate the memory"
1354
1336
" for the buffer pool\n");
1546
1528
if (create_new_db) {
1547
1529
mtr_start(&mtr);
1549
1530
fsp_header_init(0, sum_of_new_sizes, &mtr);
1551
1532
mtr_commit(&mtr);
1553
/* To maintain backward compatibility we create only
1554
the first rollback segment before the double write buffer.
1555
All the remaining rollback segments will be created later,
1556
after the double write buffer has been created. */
1557
1534
trx_sys_create();
1561
1536
srv_startup_is_before_trx_rollback_phase = FALSE;
1563
1538
#ifdef UNIV_LOG_ARCHIVE
1637
1610
trx_sys_init_at_db_start();
1639
/* Initialize the fsp free limit global variable in the log
1641
fsp_header_get_free_limit();
1643
/* recv_recovery_from_checkpoint_finish needs trx lists which
1644
are initialized in trx_sys_init_at_db_start(). */
1646
recv_recovery_from_checkpoint_finish();
1647
1612
if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
1648
1613
/* The following call is necessary for the insert
1649
1614
buffer to work with multiple tablespaces. We must
1659
1624
every table in the InnoDB data dictionary that has
1662
We also determine the maximum tablespace id used. */
1627
We also determine the maximum tablespace id used.
1629
TODO: We may have incomplete transactions in the
1630
data dictionary tables. Does that harm the scanning of
1631
the data dictionary below? */
1664
1633
dict_check_tablespaces_and_store_max_id(
1665
1634
recv_needed_recovery);
1668
1637
srv_startup_is_before_trx_rollback_phase = FALSE;
1669
recv_recovery_rollback_active();
1639
/* Initialize the fsp free limit global variable in the log
1641
fsp_header_get_free_limit();
1643
/* recv_recovery_from_checkpoint_finish needs trx lists which
1644
are initialized in trx_sys_init_at_db_start(). */
1646
recv_recovery_from_checkpoint_finish();
1671
1648
/* It is possible that file_format tag has never
1672
1649
been set. In this case we initialize it to minimum
1715
1692
/* fprintf(stderr, "Max allowed record size %lu\n",
1716
1693
page_get_free_space_of_empty() / 2); */
1718
if (trx_doublewrite == NULL) {
1719
/* Create the doublewrite buffer to a new tablespace */
1721
trx_sys_create_doublewrite_buf();
1724
/* Here the double write buffer has already been created and so
1725
any new rollback segments will be allocated after the double
1726
write buffer. The default segment should already exist.
1727
We create the new segments only if it's a new database or
1728
the database was shutdown cleanly. */
1730
/* Note: When creating the extra rollback segments during an upgrade
1731
we violate the latching order, even if the change buffer is empty.
1732
We make an exception in sync0sync.c and check srv_is_being_started
1733
for that violation. It cannot create a deadlock because we are still
1734
running in single threaded mode essentially. Only the IO threads
1735
should be running at this stage. */
1737
trx_sys_create_rsegs(TRX_SYS_N_RSEGS - 1);
1739
/* Create the thread which watches the timeouts for lock waits */
1740
os_thread_create(&srv_lock_timeout_thread, NULL,
1695
/* Create the thread which watches the timeouts for lock waits
1696
and prints InnoDB monitor info */
1698
os_thread_create(&srv_lock_timeout_and_monitor_thread, NULL,
1741
1699
thread_ids + 2 + SRV_MAX_N_IO_THREADS);
1743
1701
/* Create the thread which warns of long semaphore waits */
1744
1702
os_thread_create(&srv_error_monitor_thread, NULL,
1745
1703
thread_ids + 3 + SRV_MAX_N_IO_THREADS);
1747
/* Create the thread which prints InnoDB monitor info */
1748
os_thread_create(&srv_monitor_thread, NULL,
1749
thread_ids + 4 + SRV_MAX_N_IO_THREADS);
1751
1704
srv_is_being_started = FALSE;
1706
if (trx_doublewrite == NULL) {
1707
/* Create the doublewrite buffer to a new tablespace */
1709
trx_sys_create_doublewrite_buf();
1753
1712
err = dict_create_or_check_foreign_constraint_tables();
1755
1714
if (err != DB_SUCCESS) {
1762
1721
os_thread_create(&srv_master_thread, NULL, thread_ids
1763
1722
+ (1 + SRV_MAX_N_IO_THREADS));
1765
/* Currently we allow only a single purge thread. */
1766
ut_a(srv_n_purge_threads == 0 || srv_n_purge_threads == 1);
1768
/* If the user has requested a separate purge thread then
1769
start the purge thread. */
1770
if (srv_n_purge_threads == 1) {
1771
os_thread_create(&srv_purge_thread, NULL, NULL);
1774
1723
#ifdef UNIV_DEBUG
1775
1724
/* buf_debug_prints = TRUE; */
1776
1725
#endif /* UNIV_DEBUG */
1864
1813
if (srv_print_verbose_log) {
1865
1814
ut_print_timestamp(stderr);
1866
1815
fprintf(stderr,
1867
" InnoDB %s started; "
1816
" InnoDB Plugin %s started; "
1868
1817
"log sequence number %"PRIu64"\n",
1869
1818
INNODB_VERSION_STR, srv_start_lsn);
2018
1973
/* c. We wake the master thread so that it exits */
2019
1974
srv_wake_master_thread();
2021
/* d. We wake the purge thread so that it exits */
2022
srv_wake_purge_thread();
2024
/* e. Exit the i/o threads */
1976
/* d. Exit the i/o threads */
2026
1978
os_aio_wake_all_threads_at_shutdown();
2031
1983
/* All the threads have exited or are just exiting;
2032
1984
NOTE that the threads may not have completed their
2033
1985
exit yet. Should we use pthread_join() to make sure
2034
they have exited? If we did, we would have to
2035
remove the pthread_detach() from
2036
os_thread_exit(). Now we just sleep 0.1
2037
seconds and hope that is enough! */
1986
they have exited? Now we just sleep 0.1 seconds and
1987
hope that is enough! */
2039
1989
os_mutex_exit(os_sync_mutex);
2073
2023
srv_misc_tmpfile = 0;
2076
/* This must be disabled before closing the buffer pool
2077
and closing the data dictionary. */
2078
btr_search_disable();
2084
2026
trx_sys_file_format_close();
2087
2028
mutex_free(&srv_monitor_file_mutex);
2088
2029
mutex_free(&srv_dict_tmpfile_mutex);
2089
2030
mutex_free(&srv_misc_tmpfile_mutex);
2091
btr_search_sys_free();
2093
2032
/* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
2036
/* 4. Free the os_conc_mutex and all os_events and os_mutexes */
2100
/* 4. Free the os_conc_mutex and all os_events and os_mutexes */
2102
2039
os_sync_free();
2104
/* 5. Free all allocated memory */
2108
buf_pool_free(srv_buf_pool_instances);
2111
/* ut_free_all_mem() frees all allocated memory not freed yet
2112
in shutdown, and it will also free the ut_list_mutex, so it
2113
should be the last one for all operation */
2041
/* Check that all read views are closed except read view owned
2044
if (UT_LIST_GET_LEN(trx_sys->view_list) > 1) {
2046
"InnoDB: Error: all read views were not closed"
2047
" before shutdown:\n"
2048
"InnoDB: %lu read views open \n",
2049
UT_LIST_GET_LEN(trx_sys->view_list) - 1);
2052
/* 5. Free all allocated memory and the os_fast_mutex created in
2114
2056
ut_free_all_mem();
2116
2058
if (os_thread_count != 0
2144
2086
srv_was_started = FALSE;
2145
srv_start_has_been_called = FALSE;
2147
2088
return((int) DB_SUCCESS);
2092
void set_panic_flag_for_netware()
2094
extern ibool panic_shutdown;
2095
panic_shutdown = TRUE;
2097
#endif /* __NETWARE__ */
2149
2098
#endif /* !UNIV_HOTBACKUP */