~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

[patch 112/129] Merge patch for revision 1925 from InnoDB SVN:
revno: 1925
revision-id: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6169
parent: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6163
committer: calvin
timestamp: Thu 2009-11-12 12:40:43 +0000
message:
  branches/zip: add test case for bug#46676
  
  This crash is reproducible with InnoDB plugin 1.0.4 + MySQL 5.1.37.
  But no longer reproducible after MySQL 5.1.38 (with plugin 1.0.5).
  Add test case to catch future regression.
added:
  mysql-test/innodb_bug46676.result 6169@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb_bug46676.result
  mysql-test/innodb_bug46676.test 6169@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb_bug46676.test
diff:
=== added file 'mysql-test/innodb_bug46676.result'

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
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.
6
5
 
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.
12
11
 
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
18
 
COPYING.Percona.
19
 
 
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
31
23
 
32
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
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
49
 
 
50
***********************************************************************/
33
51
 
34
52
/********************************************************************//**
35
53
@file srv/srv0start.c
87
105
# include "btr0pcur.h"
88
106
# include "thr0loc.h"
89
107
# include "os0sync.h" /* for INNODB_RW_LOCKS_USE_ATOMICS */
90
 
# include "zlib.h" /* for ZLIB_VERSION */
91
108
 
92
109
#include <errno.h>
93
110
#include <unistd.h>
129
146
static ulint            ios;
130
147
 
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];
135
152
 
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. */
145
162
#define SRV_N_PENDING_IOS_PER_THREAD    OS_AIO_N_PENDING_IOS_PER_THREAD
146
163
#define SRV_MAX_N_PENDING_SYNC_IOS      100
147
164
 
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 */
156
 
 
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 */
161
165
 
162
166
/*********************************************************************//**
163
167
Convert a numeric string that optionally ends in G or M, to a number
479
483
                        the aio array */
480
484
{
481
485
        ulint   segment;
 
486
        ulint   i;
482
487
 
483
488
        segment = *((ulint*)arg);
484
489
 
486
491
        fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,
487
492
                os_thread_pf(os_thread_get_curr_id()));
488
493
#endif
489
 
 
490
 
#ifdef UNIV_PFS_THREAD
491
 
        pfs_register_thread(io_handler_thread_key);
492
 
#endif /* UNIV_PFS_THREAD */
493
 
 
494
 
        while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) {
 
494
        for (i = 0;; i++) {
495
495
                fil_aio_wait(segment);
496
496
 
497
497
                mutex_enter(&ios_mutex);
505
505
        thread should always use that to exit and not use return() to exit.
506
506
        The thread actually never comes here because it is exited in an
507
507
        os_event_wait(). */
 
508
#if (!defined(__SUNPRO_C) && !defined(__SUNPRO_CC))
508
509
        return 0;
 
510
#endif
509
511
}
510
512
#endif /* !UNIV_HOTBACKUP */
511
513
 
601
603
 
602
604
        sprintf(name + dirnamelen, "%s%lu", "ib_logfile", (ulong) i);
603
605
 
604
 
        files[i] = os_file_create(innodb_file_log_key, name,
605
 
                                  OS_FILE_CREATE, OS_FILE_NORMAL,
 
606
        files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL,
606
607
                                  OS_LOG_FILE, &ret);
607
608
        if (ret == FALSE) {
608
609
                if (os_file_get_last_error(FALSE) != OS_FILE_ALREADY_EXISTS
620
621
                        return(DB_ERROR);
621
622
                }
622
623
 
623
 
                files[i] = os_file_create(innodb_file_log_key, name,
624
 
                                          OS_FILE_OPEN, OS_FILE_AIO,
 
624
                files[i] = os_file_create(name, OS_FILE_OPEN, OS_FILE_AIO,
625
625
                                          OS_LOG_FILE, &ret);
626
626
                if (!ret) {
627
627
                        fprintf(stderr,
786
786
                        /* First we try to create the file: if it already
787
787
                        exists, ret will get value FALSE */
788
788
 
789
 
                        files[i] = os_file_create(innodb_file_data_key,
790
 
                                                  name, OS_FILE_CREATE,
 
789
                        files[i] = os_file_create(name, OS_FILE_CREATE,
791
790
                                                  OS_FILE_NORMAL,
792
791
                                                  OS_DATA_FILE, &ret);
793
792
 
814
813
                        srv_start_raw_disk_in_use = TRUE;
815
814
                        srv_created_new_raw = TRUE;
816
815
 
817
 
                        files[i] = os_file_create(innodb_file_data_key,
818
 
                                                  name, OS_FILE_OPEN_RAW,
 
816
                        files[i] = os_file_create(name, OS_FILE_OPEN_RAW,
819
817
                                                  OS_FILE_NORMAL,
820
818
                                                  OS_DATA_FILE, &ret);
821
819
                        if (!ret) {
848
846
 
849
847
                        if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
850
848
                                files[i] = os_file_create(
851
 
                                        innodb_file_data_key,
852
849
                                        name, OS_FILE_OPEN_RAW,
853
850
                                        OS_FILE_NORMAL, OS_DATA_FILE, &ret);
854
851
                        } else if (i == 0) {
855
852
                                files[i] = os_file_create(
856
 
                                        innodb_file_data_key,
857
853
                                        name, OS_FILE_OPEN_RETRY,
858
854
                                        OS_FILE_NORMAL, OS_DATA_FILE, &ret);
859
855
                        } else {
860
856
                                files[i] = os_file_create(
861
 
                                        innodb_file_data_key,
862
857
                                        name, OS_FILE_OPEN, OS_FILE_NORMAL,
863
858
                                        OS_DATA_FILE, &ret);
864
859
                        }
1001
996
 
1002
997
        ios = 0;
1003
998
 
1004
 
        mutex_create(ios_mutex_key, &ios_mutex, SYNC_NO_ORDER_CHECK);
 
999
        mutex_create(&ios_mutex, SYNC_NO_ORDER_CHECK);
1005
1000
 
1006
1001
        return(DB_SUCCESS);
1007
1002
}
1015
1010
innobase_start_or_create_for_mysql(void)
1016
1011
/*====================================*/
1017
1012
{
 
1013
        buf_pool_t*     ret;
1018
1014
        ibool           create_new_db;
1019
1015
        ibool           log_file_created;
1020
1016
        ibool           log_created     = FALSE;
1080
1076
#ifdef UNIV_IBUF_DEBUG
1081
1077
        fprintf(stderr,
1082
1078
                "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"
1086
 
# endif
1087
 
                );
 
1079
                "InnoDB: Crash recovery will fail with UNIV_IBUF_DEBUG\n");
1088
1080
#endif
1089
1081
 
1090
1082
#ifdef UNIV_SYNC_DEBUG
1111
1103
                        "InnoDB: The InnoDB memory heap is disabled\n");
1112
1104
        }
1113
1105
 
1114
 
        fputs("InnoDB: " IB_ATOMICS_STARTUP_MSG
1115
 
              "\nInnoDB: Compressed tables use zlib " ZLIB_VERSION
1116
 
#ifdef UNIV_ZIP_DEBUG
1117
 
              " with validation"
1118
 
#endif /* UNIV_ZIP_DEBUG */
1119
 
#ifdef UNIV_ZIP_COPY
1120
 
              " and extra copying"
1121
 
#endif /* UNIV_ZIP_COPY */
1122
 
              "\n" , stderr);
1123
 
 
 
1106
        fprintf(stderr, "InnoDB: %s\n", IB_ATOMICS_STARTUP_MSG);
1124
1107
 
1125
1108
        /* Since InnoDB does not currently clean up all its internal data
1126
1109
        structures in MySQL Embedded Server Library server_end(), we
1146
1129
 
1147
1130
        srv_is_being_started = TRUE;
1148
1131
        srv_startup_is_before_trx_rollback_phase = TRUE;
 
1132
        os_aio_use_native_aio = FALSE;
1149
1133
 
1150
1134
#ifdef __WIN__
1151
1135
        switch (os_get_os_version()) {
1157
1141
                but when run in conjunction with InnoDB Hot Backup, it seemed
1158
1142
                to corrupt the data files. */
1159
1143
 
1160
 
                srv_use_native_aio = FALSE;
1161
 
                break;
1162
 
 
1163
 
        case OS_WIN2000:
1164
 
        case OS_WINXP:
1165
 
                /* On 2000 and XP, async IO is available. */
1166
 
                srv_use_native_aio = TRUE;
1167
 
                break;
1168
 
 
 
1144
                os_aio_use_native_aio = FALSE;
 
1145
                break;
1169
1146
        default:
1170
 
                /* Vista and later have both async IO and condition variables */
1171
 
                srv_use_native_aio = TRUE;
1172
 
                srv_use_native_conditions = TRUE;
 
1147
                /* On Win 2000 and XP use async i/o */
 
1148
                os_aio_use_native_aio = TRUE;
1173
1149
                break;
1174
1150
        }
1175
 
 
1176
 
#elif defined(LINUX_NATIVE_AIO)
1177
 
 
1178
 
        if (srv_use_native_aio) {
1179
 
                ut_print_timestamp(stderr);
1180
 
                fprintf(stderr,
1181
 
                        "  InnoDB: Using Linux native AIO\n");
1182
 
        }
1183
 
#else
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;
1188
 
 
1189
1151
#endif
1190
 
 
1191
1152
        if (srv_file_flush_method_str == NULL) {
1192
1153
                /* These are the default options */
1193
1154
 
1212
1173
#else
1213
1174
        } else if (0 == ut_strcmp(srv_file_flush_method_str, "normal")) {
1214
1175
                srv_win_file_flush_method = SRV_WIN_IO_NORMAL;
1215
 
                srv_use_native_aio = FALSE;
 
1176
                os_aio_use_native_aio = FALSE;
1216
1177
 
1217
1178
        } else if (0 == ut_strcmp(srv_file_flush_method_str, "unbuffered")) {
1218
1179
                srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
1219
 
                srv_use_native_aio = FALSE;
 
1180
                os_aio_use_native_aio = FALSE;
1220
1181
 
1221
1182
        } else if (0 == ut_strcmp(srv_file_flush_method_str,
1222
1183
                                  "async_unbuffered")) {
1238
1199
        maximum number of threads that can wait in the 'srv_conc array' for
1239
1200
        their time to enter InnoDB. */
1240
1201
 
 
1202
#if defined(__NETWARE__)
 
1203
 
 
1204
        /* Create less event semaphores because Win 98/ME had
 
1205
        difficulty creating 40000 event semaphores.  Comment from
 
1206
        Novell, Inc.: also, these just take a lot of memory on
 
1207
        NetWare. */
 
1208
        srv_max_n_threads = 1000;
 
1209
#else
1241
1210
        if (srv_buf_pool_size >= 1000 * 1024 * 1024) {
1242
1211
                /* If buffer pool is less than 1000 MB,
1243
 
                assume fewer threads. Also use only one
1244
 
                buffer pool instance */
 
1212
                assume fewer threads. */
1245
1213
                srv_max_n_threads = 50000;
1246
1214
 
1247
1215
        } else if (srv_buf_pool_size >= 8 * 1024 * 1024) {
1248
1216
 
1249
 
                srv_buf_pool_instances = 1;
1250
1217
                srv_max_n_threads = 10000;
1251
1218
        } else {
1252
 
                srv_buf_pool_instances = 1;
1253
1219
                srv_max_n_threads = 1000;       /* saves several MB of memory,
1254
1220
                                                especially in 64-bit
1255
1221
                                                computers */
1256
1222
        }
1257
 
 
 
1223
#endif
1258
1224
        err = srv_boot();
1259
1225
 
1260
1226
        if (err != DB_SUCCESS) {
1262
1228
                return((int) err);
1263
1229
        }
1264
1230
 
1265
 
        mutex_create(srv_monitor_file_mutex_key,
1266
 
                     &srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
 
1231
        mutex_create(&srv_monitor_file_mutex, SYNC_NO_ORDER_CHECK);
1267
1232
 
1268
1233
        if (srv_innodb_status) {
1269
1234
                srv_monitor_file_name = mem_alloc(
1285
1250
                }
1286
1251
        }
1287
1252
 
1288
 
        mutex_create(srv_dict_tmpfile_mutex_key,
1289
 
                     &srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
 
1253
        mutex_create(&srv_dict_tmpfile_mutex, SYNC_DICT_OPERATION);
1290
1254
 
1291
1255
        srv_dict_tmpfile = os_file_create_tmpfile();
1292
1256
        if (!srv_dict_tmpfile) {
1293
1257
                return(DB_ERROR);
1294
1258
        }
1295
1259
 
1296
 
        mutex_create(srv_misc_tmpfile_mutex_key,
1297
 
                     &srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
 
1260
        mutex_create(&srv_misc_tmpfile_mutex, SYNC_ANY_LATCH);
1298
1261
 
1299
1262
        srv_misc_tmpfile = os_file_create_tmpfile();
1300
1263
        if (!srv_misc_tmpfile) {
1313
1276
 
1314
1277
        /* TODO: Investigate if SRV_N_PENDING_IOS_PER_THREAD (32) limit
1315
1278
        still applies to windows. */
1316
 
        if (!srv_use_native_aio) {
 
1279
        if (!os_aio_use_native_aio) {
1317
1280
                io_limit = 8 * SRV_N_PENDING_IOS_PER_THREAD;
1318
1281
        } else {
1319
1282
                io_limit = SRV_N_PENDING_IOS_PER_THREAD;
1327
1290
        fil_init(srv_file_per_table ? 50000 : 5000,
1328
1291
                 srv_max_n_open_files);
1329
1292
 
1330
 
        /* Print time to initialize the buffer pool */
1331
 
        ut_print_timestamp(stderr);
1332
 
        fprintf(stderr,
1333
 
                "  InnoDB: Initializing buffer pool, size =");
1334
 
 
1335
 
        if (srv_buf_pool_size >= 1024 * 1024 * 1024) {
1336
 
                fprintf(stderr,
1337
 
                        " %.1fG\n",
1338
 
                        ((double) srv_buf_pool_size) / (1024 * 1024 * 1024));
1339
 
        } else {
1340
 
                fprintf(stderr,
1341
 
                        " %.1fM\n",
1342
 
                        ((double) srv_buf_pool_size) / (1024 * 1024));
1343
 
        }
1344
 
 
1345
 
        err = buf_pool_init(srv_buf_pool_size, srv_buf_pool_instances);
1346
 
 
1347
 
        ut_print_timestamp(stderr);
1348
 
        fprintf(stderr,
1349
 
                "  InnoDB: Completed initialization of buffer pool\n");
1350
 
 
1351
 
        if (err != DB_SUCCESS) {
 
1293
        ret = buf_pool_init();
 
1294
 
 
1295
        if (ret == NULL) {
1352
1296
                fprintf(stderr,
1353
1297
                        "InnoDB: Fatal error: cannot allocate the memory"
1354
1298
                        " for the buffer pool\n");
1545
1489
 
1546
1490
        if (create_new_db) {
1547
1491
                mtr_start(&mtr);
1548
 
 
1549
1492
                fsp_header_init(0, sum_of_new_sizes, &mtr);
1550
1493
 
1551
1494
                mtr_commit(&mtr);
1552
1495
 
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
1496
                trx_sys_create();
1558
 
 
1559
1497
                dict_create();
1560
 
 
1561
1498
                srv_startup_is_before_trx_rollback_phase = FALSE;
1562
1499
 
1563
1500
#ifdef UNIV_LOG_ARCHIVE
1576
1513
                in any disk i/o, first call dict_boot */
1577
1514
 
1578
1515
                dict_boot();
1579
 
 
1580
1516
                trx_sys_init_at_db_start();
1581
 
 
1582
1517
                srv_startup_is_before_trx_rollback_phase = FALSE;
1583
1518
 
1584
1519
                /* Initialize the fsp free limit global variable in the log
1602
1537
                consistent state, this is REQUIRED for the recovery
1603
1538
                process to work. */
1604
1539
                err = trx_sys_file_format_max_check(
1605
 
                        srv_max_file_format_at_startup);
 
1540
                        srv_check_file_format_at_startup);
1606
1541
 
1607
1542
                if (err != DB_SUCCESS) {
1608
1543
                        return(err);
1636
1571
                dict_boot();
1637
1572
                trx_sys_init_at_db_start();
1638
1573
 
1639
 
                /* Initialize the fsp free limit global variable in the log
1640
 
                system */
1641
 
                fsp_header_get_free_limit();
1642
 
 
1643
 
                /* recv_recovery_from_checkpoint_finish needs trx lists which
1644
 
                are initialized in trx_sys_init_at_db_start(). */
1645
 
 
1646
 
                recv_recovery_from_checkpoint_finish();
1647
1574
                if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
1648
1575
                        /* The following call is necessary for the insert
1649
1576
                        buffer to work with multiple tablespaces. We must
1659
1586
                        every table in the InnoDB data dictionary that has
1660
1587
                        an .ibd file.
1661
1588
 
1662
 
                        We also determine the maximum tablespace id used. */
 
1589
                        We also determine the maximum tablespace id used.
 
1590
 
 
1591
                        TODO: We may have incomplete transactions in the
 
1592
                        data dictionary tables. Does that harm the scanning of
 
1593
                        the data dictionary below? */
1663
1594
 
1664
1595
                        dict_check_tablespaces_and_store_max_id(
1665
1596
                                recv_needed_recovery);
1666
1597
                }
1667
1598
 
1668
1599
                srv_startup_is_before_trx_rollback_phase = FALSE;
1669
 
                recv_recovery_rollback_active();
 
1600
 
 
1601
                /* Initialize the fsp free limit global variable in the log
 
1602
                system */
 
1603
                fsp_header_get_free_limit();
 
1604
 
 
1605
                /* recv_recovery_from_checkpoint_finish needs trx lists which
 
1606
                are initialized in trx_sys_init_at_db_start(). */
 
1607
 
 
1608
                recv_recovery_from_checkpoint_finish();
1670
1609
 
1671
1610
                /* It is possible that file_format tag has never
1672
1611
                been set. In this case we initialize it to minimum
1715
1654
        /* fprintf(stderr, "Max allowed record size %lu\n",
1716
1655
        page_get_free_space_of_empty() / 2); */
1717
1656
 
1718
 
        if (trx_doublewrite == NULL) {
1719
 
                /* Create the doublewrite buffer to a new tablespace */
1720
 
 
1721
 
                trx_sys_create_doublewrite_buf();
1722
 
        }
1723
 
 
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. */
1729
 
 
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. */
1736
 
 
1737
 
        trx_sys_create_rsegs(TRX_SYS_N_RSEGS - 1);
1738
 
 
1739
 
        /* Create the thread which watches the timeouts for lock waits */
1740
 
        os_thread_create(&srv_lock_timeout_thread, NULL,
 
1657
        /* Create the thread which watches the timeouts for lock waits
 
1658
        and prints InnoDB monitor info */
 
1659
 
 
1660
        os_thread_create(&srv_lock_timeout_and_monitor_thread, NULL,
1741
1661
                         thread_ids + 2 + SRV_MAX_N_IO_THREADS);
1742
1662
 
1743
1663
        /* Create the thread which warns of long semaphore waits */
1744
1664
        os_thread_create(&srv_error_monitor_thread, NULL,
1745
1665
                         thread_ids + 3 + SRV_MAX_N_IO_THREADS);
1746
 
 
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);
1750
 
 
1751
1666
        srv_is_being_started = FALSE;
1752
1667
 
 
1668
        if (trx_doublewrite == NULL) {
 
1669
                /* Create the doublewrite buffer to a new tablespace */
 
1670
 
 
1671
                trx_sys_create_doublewrite_buf();
 
1672
        }
 
1673
 
1753
1674
        err = dict_create_or_check_foreign_constraint_tables();
1754
1675
 
1755
1676
        if (err != DB_SUCCESS) {
1761
1682
 
1762
1683
        os_thread_create(&srv_master_thread, NULL, thread_ids
1763
1684
                         + (1 + SRV_MAX_N_IO_THREADS));
1764
 
 
1765
 
        /* Currently we allow only a single purge thread. */
1766
 
        ut_a(srv_n_purge_threads == 0 || srv_n_purge_threads == 1);
1767
 
 
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);
1772
 
        }
1773
 
 
1774
1685
#ifdef UNIV_DEBUG
1775
1686
        /* buf_debug_prints = TRUE; */
1776
1687
#endif /* UNIV_DEBUG */
1864
1775
        if (srv_print_verbose_log) {
1865
1776
                ut_print_timestamp(stderr);
1866
1777
                fprintf(stderr,
1867
 
                        "  InnoDB %s started; "
 
1778
                        " InnoDB Plugin %s started; "
1868
1779
                        "log sequence number %"PRIu64"\n",
1869
1780
                        INNODB_VERSION_STR, srv_start_lsn);
1870
1781
        }
1951
1862
/*=============================*/
1952
1863
{
1953
1864
        ulint   i;
 
1865
#ifdef __NETWARE__
 
1866
        extern ibool panic_shutdown;
 
1867
#endif
1954
1868
        if (!srv_was_started) {
1955
1869
                if (srv_is_being_started) {
1956
1870
                        ut_print_timestamp(stderr);
1979
1893
                        "InnoDB will do a crash recovery!\n");
1980
1894
        }
1981
1895
 
1982
 
        logs_empty_and_mark_files_at_shutdown();
 
1896
#ifdef __NETWARE__
 
1897
        if (!panic_shutdown)
 
1898
#endif
 
1899
                logs_empty_and_mark_files_at_shutdown();
1983
1900
 
1984
1901
        if (srv_conc_n_threads != 0) {
1985
1902
                fprintf(stderr,
2018
1935
                /* c. We wake the master thread so that it exits */
2019
1936
                srv_wake_master_thread();
2020
1937
 
2021
 
                /* d. We wake the purge thread so that it exits */
2022
 
                srv_wake_purge_thread();
2023
 
 
2024
 
                /* e. Exit the i/o threads */
 
1938
                /* d. Exit the i/o threads */
2025
1939
 
2026
1940
                os_aio_wake_all_threads_at_shutdown();
2027
1941
 
2105
2019
 
2106
2020
        pars_lexer_close();
2107
2021
        log_mem_free();
2108
 
        buf_pool_free(srv_buf_pool_instances);
 
2022
        buf_pool_free();
 
2023
        ut_free_all_mem();
2109
2024
        mem_close();
2110
2025
 
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 */
2114
 
        ut_free_all_mem();
2115
 
 
2116
2026
        if (os_thread_count != 0
2117
2027
            || os_event_count != 0
2118
2028
            || os_mutex_count != 0
2146
2056
 
2147
2057
        return((int) DB_SUCCESS);
2148
2058
}
 
2059
 
 
2060
#ifdef __NETWARE__
 
2061
void set_panic_flag_for_netware()
 
2062
{
 
2063
        extern ibool panic_shutdown;
 
2064
        panic_shutdown = TRUE;
 
2065
}
 
2066
#endif /* __NETWARE__ */
2149
2067
#endif /* !UNIV_HOTBACKUP */