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.
30
22
St, Fifth Floor, Boston, MA 02110-1301 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
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
50
***********************************************************************/
34
52
/********************************************************************//**
35
53
@file srv/srv0start.c
129
146
static ulint ios;
131
148
/** io_handler_thread parameters for thread identification */
132
static ulint n[SRV_MAX_N_IO_THREADS + 6];
149
static ulint n[SRV_MAX_N_IO_THREADS + 5];
133
150
/** io_handler_thread identifiers */
134
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6];
151
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 5];
136
153
/** We use this mutex to test the return value of pthread_mutex_trylock
137
154
on successful locking. HP-UX does NOT return 0, though Linux et al do. */
473
491
fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,
474
492
os_thread_pf(os_thread_get_curr_id()));
476
while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) {
477
495
fil_aio_wait(segment);
479
497
mutex_enter(&ios_mutex);
481
499
mutex_exit(&ios_mutex);
484
thr_local_free(os_thread_get_curr_id());
486
501
/* We count the number of threads in os_thread_exit(). A created
487
502
thread should always use that to exit and not use return() to exit.
488
503
The thread actually never comes here because it is exited in an
489
504
os_event_wait(). */
505
#if (!defined(__SUNPRO_C) && !defined(__SUNPRO_CC))
506
/* This is disabled on SunStudio as it (rightly) gives a warning
507
about this code never being reached. See the loop above? No exit
509
thr_local_free(os_thread_get_curr_id());
492
514
#endif /* !UNIV_HOTBACKUP */
1056
1078
#ifdef UNIV_IBUF_DEBUG
1057
1079
fprintf(stderr,
1058
1080
"InnoDB: !!!!!!!! UNIV_IBUF_DEBUG switched on !!!!!!!!!\n"
1059
# ifdef UNIV_IBUF_COUNT_DEBUG
1060
"InnoDB: !!!!!!!! UNIV_IBUF_COUNT_DEBUG switched on !!!!!!!!!\n"
1061
"InnoDB: Crash recovery will fail with UNIV_IBUF_COUNT_DEBUG\n"
1081
"InnoDB: Crash recovery will fail with UNIV_IBUF_DEBUG\n");
1066
1084
#ifdef UNIV_SYNC_DEBUG
1087
1105
"InnoDB: The InnoDB memory heap is disabled\n");
1090
fputs("InnoDB: " IB_ATOMICS_STARTUP_MSG
1091
"\nInnoDB: Compressed tables use zlib " ZLIB_VERSION
1092
#ifdef UNIV_ZIP_DEBUG
1094
#endif /* UNIV_ZIP_DEBUG */
1095
#ifdef UNIV_ZIP_COPY
1096
" and extra copying"
1097
#endif /* UNIV_ZIP_COPY */
1108
fprintf(stderr, "InnoDB: %s\n", IB_ATOMICS_STARTUP_MSG);
1101
1110
/* Since InnoDB does not currently clean up all its internal data
1102
1111
structures in MySQL Embedded Server Library server_end(), we
1565
1574
trx_sys_init_at_db_start();
1567
/* Initialize the fsp free limit global variable in the log
1569
fsp_header_get_free_limit();
1571
/* recv_recovery_from_checkpoint_finish needs trx lists which
1572
are initialized in trx_sys_init_at_db_start(). */
1574
recv_recovery_from_checkpoint_finish();
1575
1576
if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
1576
1577
/* The following call is necessary for the insert
1577
1578
buffer to work with multiple tablespaces. We must
1587
1588
every table in the InnoDB data dictionary that has
1590
We also determine the maximum tablespace id used. */
1591
We also determine the maximum tablespace id used.
1593
TODO: We may have incomplete transactions in the
1594
data dictionary tables. Does that harm the scanning of
1595
the data dictionary below? */
1592
1597
dict_check_tablespaces_and_store_max_id(
1593
1598
recv_needed_recovery);
1596
1601
srv_startup_is_before_trx_rollback_phase = FALSE;
1597
recv_recovery_rollback_active();
1603
/* Initialize the fsp free limit global variable in the log
1605
fsp_header_get_free_limit();
1607
/* recv_recovery_from_checkpoint_finish needs trx lists which
1608
are initialized in trx_sys_init_at_db_start(). */
1610
recv_recovery_from_checkpoint_finish();
1599
1612
/* It is possible that file_format tag has never
1600
1613
been set. In this case we initialize it to minimum
1643
1656
/* fprintf(stderr, "Max allowed record size %lu\n",
1644
1657
page_get_free_space_of_empty() / 2); */
1646
/* Create the thread which watches the timeouts for lock waits */
1647
os_thread_create(&srv_lock_timeout_thread, NULL,
1659
/* Create the thread which watches the timeouts for lock waits
1660
and prints InnoDB monitor info */
1662
os_thread_create(&srv_lock_timeout_and_monitor_thread, NULL,
1648
1663
thread_ids + 2 + SRV_MAX_N_IO_THREADS);
1650
1665
/* Create the thread which warns of long semaphore waits */
1651
1666
os_thread_create(&srv_error_monitor_thread, NULL,
1652
1667
thread_ids + 3 + SRV_MAX_N_IO_THREADS);
1654
/* Create the thread which prints InnoDB monitor info */
1655
os_thread_create(&srv_monitor_thread, NULL,
1656
thread_ids + 4 + SRV_MAX_N_IO_THREADS);
1658
1668
srv_is_being_started = FALSE;
1660
1670
if (trx_doublewrite == NULL) {