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
*****************************************************************************/
34
/********************************************************************//**
26
/************************************************************************
36
27
Starts the InnoDB database server
38
29
Created 2/16/1996 Heikki Tuuri
39
30
*************************************************************************/
33
#include "sync0sync.h"
41
34
#include "ut0mem.h"
42
35
#include "mem0mem.h"
43
36
#include "data0data.h"
44
37
#include "data0type.h"
45
38
#include "dict0dict.h"
46
39
#include "buf0buf.h"
47
42
#include "os0file.h"
48
43
#include "os0thread.h"
49
44
#include "fil0fil.h"
50
45
#include "fsp0fsp.h"
51
46
#include "rem0rec.h"
52
48
#include "mtr0mtr.h"
53
49
#include "log0log.h"
54
50
#include "log0recv.h"
55
51
#include "page0page.h"
56
52
#include "page0cur.h"
57
53
#include "trx0trx.h"
54
#include "dict0boot.h"
55
#include "dict0load.h"
58
56
#include "trx0sys.h"
57
#include "dict0crea.h"
59
58
#include "btr0btr.h"
60
60
#include "btr0cur.h"
61
62
#include "rem0rec.h"
66
#include "lock0lock.h"
68
#include "trx0purge.h"
73
#include "row0mysql.h"
74
#include "lock0lock.h"
62
75
#include "ibuf0ibuf.h"
76
#include "pars0pars.h"
63
78
#include "srv0start.h"
65
#ifndef UNIV_HOTBACKUP
67
# include "sync0sync.h"
70
# include "dict0boot.h"
71
# include "dict0load.h"
73
# include "usr0sess.h"
74
# include "lock0lock.h"
75
# include "trx0roll.h"
76
# include "trx0purge.h"
77
# include "lock0lock.h"
78
# include "pars0pars.h"
81
# include "dict0crea.h"
86
# include "row0mysql.h"
87
# include "btr0pcur.h"
89
# include "os0sync.h" /* for INNODB_RW_LOCKS_USE_ATOMICS */
90
# include "zlib.h" /* for ZLIB_VERSION */
95
/** Log sequence number immediately after startup */
81
/* Log sequence number immediately after startup */
96
82
UNIV_INTERN ib_uint64_t srv_start_lsn;
97
/** Log sequence number at shutdown */
83
/* Log sequence number at shutdown */
98
84
UNIV_INTERN ib_uint64_t srv_shutdown_lsn;
100
86
#ifdef HAVE_DARWIN_THREADS
101
87
# include <sys/utsname.h>
102
/** TRUE if the F_FULLFSYNC option is available */
103
88
UNIV_INTERN ibool srv_have_fullfsync = FALSE;
106
/** TRUE if a raw partition is in use */
107
91
UNIV_INTERN ibool srv_start_raw_disk_in_use = FALSE;
109
/** TRUE if the server is being started, before rolling back any
110
incomplete transactions */
111
93
UNIV_INTERN ibool srv_startup_is_before_trx_rollback_phase = FALSE;
112
/** TRUE if the server is being started */
113
94
UNIV_INTERN ibool srv_is_being_started = FALSE;
114
/** TRUE if the server was successfully started */
115
95
UNIV_INTERN ibool srv_was_started = FALSE;
116
/** TRUE if innobase_start_or_create_for_mysql() has been called */
96
#ifndef UNIV_HOTBACKUP
117
97
static ibool srv_start_has_been_called = FALSE;
119
/** At a shutdown this value climbs from SRV_SHUTDOWN_NONE to
120
SRV_SHUTDOWN_CLEANUP and then to SRV_SHUTDOWN_LAST_PHASE, and so on */
121
UNIV_INTERN enum srv_shutdown_state srv_shutdown_state = SRV_SHUTDOWN_NONE;
123
/** Files comprising the system tablespace */
98
#endif /* !UNIV_HOTBACKUP */
100
/* At a shutdown the value first climbs to SRV_SHUTDOWN_CLEANUP
101
and then to SRV_SHUTDOWN_LAST_PHASE */
102
UNIV_INTERN ulint srv_shutdown_state = 0;
104
#ifndef UNIV_HOTBACKUP
124
105
static os_file_t files[1000];
126
/** Mutex protecting the ios count */
127
107
static mutex_t ios_mutex;
128
/** Count of I/O operations in io_handler_thread() */
129
108
static ulint ios;
131
/** io_handler_thread parameters for thread identification */
132
static ulint n[SRV_MAX_N_IO_THREADS + 6];
133
/** io_handler_thread identifiers */
134
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6];
110
static ulint n[SRV_MAX_N_IO_THREADS + 5];
111
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 5];
136
/** We use this mutex to test the return value of pthread_mutex_trylock
113
/* We use this mutex to test the return value of pthread_mutex_trylock
137
114
on successful locking. HP-UX does NOT return 0, though Linux et al do. */
138
115
static os_fast_mutex_t srv_os_test_mutex;
140
/** Name of srv_monitor_file */
117
/* Name of srv_monitor_file */
141
118
static char* srv_monitor_file_name;
142
119
#endif /* !UNIV_HOTBACKUP */
145
121
#define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD
146
122
#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
/*********************************************************************//**
163
Convert a numeric string that optionally ends in G or M, to a number
164
containing megabytes.
165
@return next character in string */
168
127
srv_parse_megabytes(
169
128
/*================*/
170
char* str, /*!< in: string containing a quantity in bytes */
171
ulint* megs) /*!< out: the number in megabytes */
129
/* out: next character in string */
130
char* str, /* in: string containing a quantity in bytes */
131
ulint* megs) /* out: the number in megabytes */
492
/*************************************************************************
493
Adds a slash or a backslash to the end of a string if it is missing
494
and the string is not empty. */
497
srv_add_path_separator_if_needed(
498
/*=============================*/
499
/* out: string which has the separator if the
500
string is not empty */
501
char* str) /* in: null-terminated character string */
504
ulint len = ut_strlen(str);
506
if (len == 0 || str[len - 1] == SRV_PATH_SEPARATOR) {
511
out_str = ut_malloc(len + 2);
512
memcpy(out_str, str, len);
513
out_str[len] = SRV_PATH_SEPARATOR;
514
out_str[len + 1] = 0;
537
519
#ifndef UNIV_HOTBACKUP
538
/*********************************************************************//**
520
/*************************************************************************
539
521
Calculates the low 32 bits when a file size which is given as a number
540
database pages is converted to the number of bytes.
541
@return low 32 bytes of file size when expressed in bytes */
522
database pages is converted to the number of bytes. */
546
ulint file_size) /*!< in: file size in database pages */
527
/* out: low 32 bytes of file size when
528
expressed in bytes */
529
ulint file_size) /* in: file size in database pages */
548
531
return(0xFFFFFFFFUL & (file_size << UNIV_PAGE_SIZE_SHIFT));
551
/*********************************************************************//**
534
/*************************************************************************
552
535
Calculates the high 32 bits when a file size which is given as a number
553
database pages is converted to the number of bytes.
554
@return high 32 bytes of file size when expressed in bytes */
536
database pages is converted to the number of bytes. */
559
ulint file_size) /*!< in: file size in database pages */
541
/* out: high 32 bytes of file size when
542
expressed in bytes */
543
ulint file_size) /* in: file size in database pages */
561
545
return(file_size >> (32 - UNIV_PAGE_SIZE_SHIFT));
564
/*********************************************************************//**
565
Creates or opens the log files and closes them.
566
@return DB_SUCCESS or error code */
548
/*************************************************************************
549
Creates or opens the log files and closes them. */
569
552
open_or_create_log_file(
570
553
/*====================*/
571
ibool create_new_db, /*!< in: TRUE if we should create a
554
/* out: DB_SUCCESS or error code */
555
ibool create_new_db, /* in: TRUE if we should create a
573
ibool* log_file_created, /*!< out: TRUE if new log file
557
ibool* log_file_created, /* out: TRUE if new log file
575
ibool log_file_has_been_opened,/*!< in: TRUE if a log file has been
559
ibool log_file_has_been_opened,/* in: TRUE if a log file has been
576
560
opened before: then it is an error
577
561
to try to create another log file */
578
ulint k, /*!< in: log group number */
579
ulint i) /*!< in: log file number in group */
562
ulint k, /* in: log group number */
563
ulint i) /* in: log file number in group */
584
568
char name[10000];
587
570
UT_NOT_USED(create_new_db);
589
572
*log_file_created = FALSE;
591
574
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,
575
srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed(
576
srv_log_group_home_dirs[k]);
578
ut_a(strlen(srv_log_group_home_dirs[k])
579
< (sizeof name) - 10 - sizeof "ib_logfile");
580
sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k],
581
"ib_logfile", (ulong) i);
583
files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL,
606
584
OS_LOG_FILE, &ret);
607
585
if (ret == FALSE) {
608
586
if (os_file_get_last_error(FALSE) != OS_FILE_ALREADY_EXISTS
721
698
return(DB_SUCCESS);
724
/*********************************************************************//**
725
Creates or opens database data files and closes them.
726
@return DB_SUCCESS or error code */
701
/*************************************************************************
702
Creates or opens database data files and closes them. */
729
705
open_or_create_data_files(
730
706
/*======================*/
731
ibool* create_new_db, /*!< out: TRUE if new database should be
707
/* out: DB_SUCCESS or error code */
708
ibool* create_new_db, /* out: TRUE if new database should be
733
710
#ifdef UNIV_LOG_ARCHIVE
734
ulint* min_arch_log_no,/*!< out: min of archived log
711
ulint* min_arch_log_no,/* out: min of archived log
735
712
numbers in data files */
736
ulint* max_arch_log_no,/*!< out: max of archived log
713
ulint* max_arch_log_no,/* out: max of archived log
737
714
numbers in data files */
738
715
#endif /* UNIV_LOG_ARCHIVE */
739
ib_uint64_t* min_flushed_lsn,/*!< out: min of flushed lsn
740
values in data files */
741
ib_uint64_t* max_flushed_lsn,/*!< out: max of flushed lsn
742
values in data files */
743
ulint* sum_of_new_sizes)/*!< out: sum of sizes of the
716
ib_uint64_t* min_flushed_lsn,/* out: min of flushed lsn
717
values in data files */
718
ib_uint64_t* max_flushed_lsn,/* out: max of flushed lsn
719
values in data files */
720
ulint* sum_of_new_sizes)/* out: sum of sizes of the
744
721
new files added */
764
741
*create_new_db = FALSE;
766
743
srv_normalize_path_for_win(srv_data_home);
744
srv_data_home = srv_add_path_separator_if_needed(srv_data_home);
768
746
for (i = 0; i < srv_n_data_files; i++) {
771
747
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])
749
ut_a(strlen(srv_data_home) + strlen(srv_data_file_names[i])
775
750
< (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]);
751
sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]);
784
753
if (srv_data_file_is_raw_partition[i] == 0) {
786
755
/* First we try to create the file: if it already
787
756
exists, ret will get value FALSE */
789
files[i] = os_file_create(innodb_file_data_key,
790
name, OS_FILE_CREATE,
758
files[i] = os_file_create(name, OS_FILE_CREATE,
792
760
OS_DATA_FILE, &ret);
1111
1067
"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 */
1070
#ifdef HAVE_GCC_ATOMIC_BUILTINS
1071
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
1073
"InnoDB: Mutexes and rw_locks use GCC atomic builtins.\n");
1074
#else /* INNODB_RW_LOCKS_USE_ATOMICS */
1076
"InnoDB: Mutexes use GCC atomic builtins, rw_locks do not.\n");
1077
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1078
#else /* HAVE_GCC_ATOMIC_BUILTINS */
1080
"InnoDB: Neither mutexes nor rw_locks use GCC atomic builtins.\n");
1081
#endif /* HAVE_GCC_ATOMIC_BUILTINS */
1125
1083
/* Since InnoDB does not currently clean up all its internal data
1126
1084
structures in MySQL Embedded Server Library server_end(), we
1147
1105
srv_is_being_started = TRUE;
1148
1106
srv_startup_is_before_trx_rollback_phase = TRUE;
1107
os_aio_use_native_aio = FALSE;
1151
switch (os_get_os_version()) {
1110
if (os_get_os_version() == OS_WIN95
1111
|| os_get_os_version() == OS_WIN31
1112
|| os_get_os_version() == OS_WINNT) {
1155
1114
/* On Win 95, 98, ME, Win32 subsystem for Windows 3.1,
1156
1115
and NT use simulated aio. In NT Windows provides async i/o,
1157
1116
but when run in conjunction with InnoDB Hot Backup, it seemed
1158
1117
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;
1170
/* Vista and later have both async IO and condition variables */
1171
srv_use_native_aio = TRUE;
1172
srv_use_native_conditions = 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;
1119
os_aio_use_native_aio = FALSE;
1121
/* On Win 2000 and XP use async i/o */
1122
os_aio_use_native_aio = TRUE;
1191
1125
if (srv_file_flush_method_str == NULL) {
1192
1126
/* These are the default options */
1238
1172
maximum number of threads that can wait in the 'srv_conc array' for
1239
1173
their time to enter InnoDB. */
1175
#if defined(__NETWARE__)
1177
/* Create less event semaphores because Win 98/ME had
1178
difficulty creating 40000 event semaphores. Comment from
1179
Novell, Inc.: also, these just take a lot of memory on
1181
srv_max_n_threads = 1000;
1241
1183
if (srv_buf_pool_size >= 1000 * 1024 * 1024) {
1242
1184
/* If buffer pool is less than 1000 MB,
1243
assume fewer threads. Also use only one
1244
buffer pool instance */
1185
assume fewer threads. */
1245
1186
srv_max_n_threads = 50000;
1247
1188
} else if (srv_buf_pool_size >= 8 * 1024 * 1024) {
1249
srv_buf_pool_instances = 1;
1250
1190
srv_max_n_threads = 10000;
1252
srv_buf_pool_instances = 1;
1253
1192
srv_max_n_threads = 1000; /* saves several MB of memory,
1254
1193
especially in 64-bit
1258
1197
err = srv_boot();
1260
1199
if (err != DB_SUCCESS) {
1288
mutex_create(srv_dict_tmpfile_mutex_key,
1289
&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1226
mutex_create(&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1291
1228
srv_dict_tmpfile = os_file_create_tmpfile();
1292
1229
if (!srv_dict_tmpfile) {
1293
1230
return(DB_ERROR);
1296
mutex_create(srv_misc_tmpfile_mutex_key,
1297
&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1233
mutex_create(&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1299
1235
srv_misc_tmpfile = os_file_create_tmpfile();
1300
1236
if (!srv_misc_tmpfile) {
1301
1237
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. */
1308
/* Now overwrite the value on srv_n_file_io_threads */
1309
srv_n_file_io_threads = 2 + srv_n_read_io_threads
1310
+ srv_n_write_io_threads;
1312
ut_a(srv_n_file_io_threads <= SRV_MAX_N_IO_THREADS);
1314
/* TODO: Investigate if SRV_N_PENDING_IOS_PER_THREAD (32) limit
1315
still applies to windows. */
1316
if (!srv_use_native_aio) {
1317
io_limit = 8 * SRV_N_PENDING_IOS_PER_THREAD;
1319
io_limit = SRV_N_PENDING_IOS_PER_THREAD;
1322
os_aio_init(io_limit,
1323
srv_n_read_io_threads,
1324
srv_n_write_io_threads,
1325
SRV_MAX_N_PENDING_SYNC_IOS);
1327
fil_init(srv_file_per_table ? 50000 : 5000,
1328
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) {
1240
/* Restrict the maximum number of file i/o threads */
1241
if (srv_n_file_io_threads > SRV_MAX_N_IO_THREADS) {
1243
srv_n_file_io_threads = SRV_MAX_N_IO_THREADS;
1246
if (!os_aio_use_native_aio) {
1247
/* In simulated aio we currently have use only for 4 threads */
1248
srv_n_file_io_threads = 4;
1250
os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
1251
* srv_n_file_io_threads,
1252
srv_n_file_io_threads,
1253
SRV_MAX_N_PENDING_SYNC_IOS);
1255
os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
1256
* srv_n_file_io_threads,
1257
srv_n_file_io_threads,
1258
SRV_MAX_N_PENDING_SYNC_IOS);
1261
fil_init(srv_max_n_open_files);
1263
ret = buf_pool_init();
1352
1266
fprintf(stderr,
1353
1267
"InnoDB: Fatal error: cannot allocate the memory"
1354
1268
" for the buffer pool\n");
1659
1556
every table in the InnoDB data dictionary that has
1662
We also determine the maximum tablespace id used. */
1559
We also determine the maximum tablespace id used.
1561
TODO: We may have incomplete transactions in the
1562
data dictionary tables. Does that harm the scanning of
1563
the data dictionary below? */
1664
1565
dict_check_tablespaces_and_store_max_id(
1665
1566
recv_needed_recovery);
1668
1569
srv_startup_is_before_trx_rollback_phase = FALSE;
1669
recv_recovery_rollback_active();
1571
/* Initialize the fsp free limit global variable in the log
1573
fsp_header_get_free_limit();
1575
/* recv_recovery_from_checkpoint_finish needs trx lists which
1576
are initialized in trx_sys_init_at_db_start(). */
1578
recv_recovery_from_checkpoint_finish();
1671
1580
/* It is possible that file_format tag has never
1672
1581
been set. In this case we initialize it to minimum
1715
1624
/* fprintf(stderr, "Max allowed record size %lu\n",
1716
1625
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,
1627
/* Create the thread which watches the timeouts for lock waits
1628
and prints InnoDB monitor info */
1630
os_thread_create(&srv_lock_timeout_and_monitor_thread, NULL,
1741
1631
thread_ids + 2 + SRV_MAX_N_IO_THREADS);
1743
1633
/* Create the thread which warns of long semaphore waits */
1744
1634
os_thread_create(&srv_error_monitor_thread, NULL,
1745
1635
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
1636
srv_is_being_started = FALSE;
1638
if (trx_doublewrite == NULL) {
1639
/* Create the doublewrite buffer to a new tablespace */
1641
trx_sys_create_doublewrite_buf();
1753
1644
err = dict_create_or_check_foreign_constraint_tables();
1755
1646
if (err != DB_SUCCESS) {
2073
1956
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
1959
trx_sys_file_format_close();
2087
1961
mutex_free(&srv_monitor_file_mutex);
2088
1962
mutex_free(&srv_dict_tmpfile_mutex);
2089
1963
mutex_free(&srv_misc_tmpfile_mutex);
2091
btr_search_sys_free();
2093
1965
/* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
1969
/* 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
1972
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 */
1974
/* Check that all read views are closed except read view owned
1977
if (UT_LIST_GET_LEN(trx_sys->view_list) > 1) {
1979
"InnoDB: Error: all read views were not closed"
1980
" before shutdown:\n"
1981
"InnoDB: %lu read views open \n",
1982
UT_LIST_GET_LEN(trx_sys->view_list) - 1);
1985
/* 5. Free all allocated memory and the os_fast_mutex created in
2114
1989
ut_free_all_mem();
2116
1991
if (os_thread_count != 0