~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/trx/trx0sys.c

  • Committer: Monty Taylor
  • Date: 2010-11-26 22:50:54 UTC
  • mfrom: (1953.1.6 build)
  • Revision ID: mordred@inaugust.com-20101126225054-sg90svw8579t5p3i
Stewart - InnoDB 1.1.1
Monty - Fixed some autoconf tests which were returning false positives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include "srv0srv.h"
40
40
#include "trx0purge.h"
41
41
#include "log0log.h"
 
42
#include "log0recv.h"
42
43
#include "os0file.h"
43
44
#include "read0read.h"
44
45
 
126
127
static const ulint      FILE_FORMAT_NAME_N
127
128
        = sizeof(file_format_name_map) / sizeof(file_format_name_map[0]);
128
129
 
 
130
#ifdef UNIV_PFS_MUTEX
 
131
/* Key to register the mutex with performance schema */
 
132
UNIV_INTERN mysql_pfs_key_t     trx_doublewrite_mutex_key;
 
133
UNIV_INTERN mysql_pfs_key_t     file_format_max_mutex_key;
 
134
#endif /* UNIV_PFS_MUTEX */
 
135
 
129
136
#ifndef UNIV_HOTBACKUP
130
137
/** This is used to track the maximum file format id known to InnoDB. It's
131
 
updated via SET GLOBAL innodb_file_format_check = 'x' or when we open
 
138
updated via SET GLOBAL innodb_file_format_max = 'x' or when we open
132
139
or create a table. */
133
140
static  file_format_t   file_format_max;
134
141
 
179
186
        os_do_not_call_flush_at_each_write = TRUE;
180
187
#endif /* UNIV_DO_FLUSH */
181
188
 
182
 
        mutex_create(&trx_doublewrite->mutex, SYNC_DOUBLEWRITE);
 
189
        mutex_create(trx_doublewrite_mutex_key,
 
190
                     &trx_doublewrite->mutex, SYNC_DOUBLEWRITE);
183
191
 
184
192
        trx_doublewrite->first_free = 0;
185
193
 
870
878
        buf_block_t*    block;
871
879
        page_t*         page;
872
880
        ulint           page_no;
873
 
        ulint           i;
 
881
        byte*           ptr;
 
882
        ulint           len;
874
883
 
875
884
        ut_ad(mtr);
876
885
 
903
912
        sys_header = trx_sysf_get(mtr);
904
913
 
905
914
        /* Start counting transaction ids from number 1 up */
906
 
        mlog_write_dulint(sys_header + TRX_SYS_TRX_ID_STORE,
907
 
                          ut_dulint_create(0, 1), mtr);
908
 
 
909
 
        /* Reset the rollback segment slots */
910
 
        for (i = 0; i < TRX_SYS_N_RSEGS; i++) {
911
 
 
912
 
                trx_sysf_rseg_set_space(sys_header, i, ULINT_UNDEFINED, mtr);
913
 
                trx_sysf_rseg_set_page_no(sys_header, i, FIL_NULL, mtr);
914
 
        }
915
 
 
916
 
        /* The remaining area (up to the page trailer) is uninitialized.
917
 
        Silence Valgrind warnings about it. */
918
 
        UNIV_MEM_VALID(sys_header + (TRX_SYS_RSEGS
919
 
                                     + TRX_SYS_N_RSEGS * TRX_SYS_RSEG_SLOT_SIZE
920
 
                                     + TRX_SYS_RSEG_SPACE),
921
 
                       (UNIV_PAGE_SIZE - FIL_PAGE_DATA_END
922
 
                        - (TRX_SYS_RSEGS
923
 
                           + TRX_SYS_N_RSEGS * TRX_SYS_RSEG_SLOT_SIZE
924
 
                           + TRX_SYS_RSEG_SPACE))
925
 
                       + page - sys_header);
 
915
        mach_write_to_8(sys_header + TRX_SYS_TRX_ID_STORE,
 
916
                        ut_dulint_create(0, 1));
 
917
 
 
918
        /* Reset the rollback segment slots.  Old versions of InnoDB
 
919
        define TRX_SYS_N_RSEGS as 256 (TRX_SYS_OLD_N_RSEGS) and expect
 
920
        that the whole array is initialized. */
 
921
        ptr = TRX_SYS_RSEGS + sys_header;
 
922
        len = ut_max(TRX_SYS_OLD_N_RSEGS, TRX_SYS_N_RSEGS)
 
923
                * TRX_SYS_RSEG_SLOT_SIZE;
 
924
        memset(ptr, 0xff, len);
 
925
        ptr += len;
 
926
        ut_a(ptr <= page + (UNIV_PAGE_SIZE - FIL_PAGE_DATA_END));
 
927
 
 
928
        /* Initialize all of the page.  This part used to be uninitialized. */
 
929
        memset(ptr, 0, UNIV_PAGE_SIZE - FIL_PAGE_DATA_END + page - ptr);
 
930
 
 
931
        mlog_log_string(sys_header, UNIV_PAGE_SIZE - FIL_PAGE_DATA_END
 
932
                        + page - sys_header, mtr);
926
933
 
927
934
        /* Create the first rollback segment in the SYSTEM tablespace */
928
 
        page_no = trx_rseg_header_create(TRX_SYS_SPACE, 0, ULINT_MAX, &slot_no,
 
935
        slot_no = trx_sysf_rseg_find_free(mtr);
 
936
        page_no = trx_rseg_header_create(TRX_SYS_SPACE, 0, ULINT_MAX, slot_no,
929
937
                                         mtr);
930
938
        ut_a(slot_no == TRX_SYS_SYSTEM_RSEG_ID);
931
 
        ut_a(page_no != FIL_NULL);
 
939
        ut_a(page_no == FSP_FIRST_RSEG_PAGE_NO);
932
940
 
933
941
        mutex_exit(&kernel_mutex);
934
942
}
1152
1160
        if (format_id == ULINT_UNDEFINED) {
1153
1161
                /* Format ID was not set. Set it to minimum possible
1154
1162
                value. */
1155
 
                format_id = DICT_TF_FORMAT_51;
 
1163
                format_id = DICT_TF_FORMAT_MIN;
1156
1164
        }
1157
1165
 
1158
1166
        ut_print_timestamp(stderr);
1232
1240
 
1233
1241
        /* If format_id is not set then set it to the minimum. */
1234
1242
        if (format_id == ULINT_UNDEFINED) {
1235
 
                trx_sys_file_format_max_set(DICT_TF_FORMAT_51, NULL);
 
1243
                trx_sys_file_format_max_set(DICT_TF_FORMAT_MIN, NULL);
1236
1244
        }
1237
1245
}
1238
1246
 
1283
1291
trx_sys_file_format_init(void)
1284
1292
/*==========================*/
1285
1293
{
1286
 
        mutex_create(&file_format_max.mutex, SYNC_FILE_FORMAT_TAG);
 
1294
        mutex_create(file_format_max_mutex_key,
 
1295
                     &file_format_max.mutex, SYNC_FILE_FORMAT_TAG);
1287
1296
 
1288
1297
        /* We don't need a mutex here, as this function should only
1289
1298
        be called once at start up. */
1290
 
        file_format_max.id = DICT_TF_FORMAT_51;
 
1299
        file_format_max.id = DICT_TF_FORMAT_MIN;
1291
1300
 
1292
1301
        file_format_max.name = trx_sys_file_format_id_to_name(
1293
1302
                file_format_max.id);
1302
1311
{
1303
1312
        /* Does nothing at the moment */
1304
1313
}
 
1314
 
 
1315
/*********************************************************************
 
1316
Creates the rollback segments */
 
1317
UNIV_INTERN
 
1318
void
 
1319
trx_sys_create_rsegs(
 
1320
/*=================*/
 
1321
        ulint   n_rsegs)        /*!< number of rollback segments to create */
 
1322
{
 
1323
        ulint   new_rsegs = 0;
 
1324
 
 
1325
        /* Do not create additional rollback segments if
 
1326
        innodb_force_recovery has been set and the database
 
1327
        was not shutdown cleanly. */
 
1328
        if (!srv_force_recovery && !recv_needed_recovery) {
 
1329
                ulint   i;
 
1330
 
 
1331
                for (i = 0;  i < n_rsegs; ++i) {
 
1332
 
 
1333
                        if (trx_rseg_create() != NULL) {
 
1334
                                ++new_rsegs;
 
1335
                        } else {
 
1336
                                break;
 
1337
                        }
 
1338
                }
 
1339
        }
 
1340
 
 
1341
        if (new_rsegs > 0) {
 
1342
                fprintf(stderr,
 
1343
                        "InnoDB: %lu rollback segment(s) active.\n",
 
1344
                        new_rsegs);
 
1345
        }
 
1346
}
 
1347
 
1305
1348
#else /* !UNIV_HOTBACKUP */
1306
1349
/*****************************************************************//**
1307
1350
Prints to stderr the MySQL binlog info in the system header if the
1376
1419
        dulint          file_format_id;
1377
1420
 
1378
1421
        *format_id = ULINT_UNDEFINED;
1379
 
        
 
1422
 
1380
1423
        file = os_file_create_simple_no_error_handling(
 
1424
                innodb_file_data_key,
1381
1425
                pathname,
1382
1426
                OS_FILE_OPEN,
1383
1427
                OS_FILE_READ_ONLY,
1456
1500
        ib_uint32_t     flags;
1457
1501
 
1458
1502
        *format_id = ULINT_UNDEFINED;
1459
 
        
 
1503
 
1460
1504
        file = os_file_create_simple_no_error_handling(
 
1505
                innodb_file_data_key,
1461
1506
                pathname,
1462
1507
                OS_FILE_OPEN,
1463
1508
                OS_FILE_READ_ONLY,