Merge branch 'merge-innodb-5.6' into 10.0

This commit is contained in:
Sergei Golubchik 2015-06-16 11:08:23 +02:00
commit a65162a396
16 changed files with 449 additions and 249 deletions

View File

@ -595,6 +595,21 @@ ib_trx_begin(
return(static_cast<ib_trx_t>(trx)); return(static_cast<ib_trx_t>(trx));
} }
/*****************************************************************//**
Check if transaction is read_only
@return transaction read_only status */
UNIV_INTERN
ib_u32_t
ib_trx_read_only(
/*=============*/
ib_trx_t ib_trx) /*!< in: trx handle */
{
trx_t* trx = (trx_t*) ib_trx;
return(trx->read_only);
}
/*****************************************************************//** /*****************************************************************//**
Get the transaction's state. Get the transaction's state.
@return transaction state */ @return transaction state */

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc. Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
@ -486,6 +486,79 @@ buf_page_is_zeroes(
return(true); return(true);
} }
/** Checks if the page is in crc32 checksum format.
@param[in] read_buf database page
@param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field
@return true if the page is in crc32 checksum format */
UNIV_INLINE
bool
buf_page_is_checksum_valid_crc32(
const byte* read_buf,
ulint checksum_field1,
ulint checksum_field2)
{
ib_uint32_t crc32 = buf_calc_page_crc32(read_buf);
return(checksum_field1 == crc32 && checksum_field2 == crc32);
}
/** Checks if the page is in innodb checksum format.
@param[in] read_buf database page
@param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field
@return true if the page is in innodb checksum format */
UNIV_INLINE
bool
buf_page_is_checksum_valid_innodb(
const byte* read_buf,
ulint checksum_field1,
ulint checksum_field2)
{
/* There are 2 valid formulas for
checksum_field2 (old checksum field) which algo=innodb could have
written to the page:
1. Very old versions of InnoDB only stored 8 byte lsn to the
start and the end of the page.
2. Newer InnoDB versions store the old formula checksum
(buf_calc_page_old_checksum()). */
if (checksum_field2 != mach_read_from_4(read_buf + FIL_PAGE_LSN)
&& checksum_field2 != buf_calc_page_old_checksum(read_buf)) {
return(false);
}
/* old field is fine, check the new field */
/* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
(always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
if (checksum_field1 != 0
&& checksum_field1 != buf_calc_page_new_checksum(read_buf)) {
return(false);
}
return(true);
}
/** Checks if the page is in none checksum format.
@param[in] read_buf database page
@param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field
@return true if the page is in none checksum format */
UNIV_INLINE
bool
buf_page_is_checksum_valid_none(
const byte* read_buf,
ulint checksum_field1,
ulint checksum_field2)
{
return(checksum_field1 == checksum_field2
&& checksum_field1 == BUF_NO_CHECKSUM_MAGIC);
}
/********************************************************************//** /********************************************************************//**
Checks if a page is corrupt. Checks if a page is corrupt.
@return TRUE if corrupted */ @return TRUE if corrupted */
@ -501,8 +574,6 @@ buf_page_is_corrupted(
{ {
ulint checksum_field1; ulint checksum_field1;
ulint checksum_field2; ulint checksum_field2;
ibool crc32_inited = FALSE;
ib_uint32_t crc32 = ULINT32_UNDEFINED;
if (!zip_size if (!zip_size
&& memcmp(read_buf + FIL_PAGE_LSN + 4, && memcmp(read_buf + FIL_PAGE_LSN + 4,
@ -582,148 +653,121 @@ buf_page_is_corrupted(
return(FALSE); return(FALSE);
} }
switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) { DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); );
ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET);
ulint space_id = mach_read_from_4(read_buf + FIL_PAGE_SPACE_ID);
const srv_checksum_algorithm_t curr_algo =
static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
crc32 = buf_calc_page_crc32(read_buf); if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2)) {
return(FALSE);
}
return(checksum_field1 != crc32 || checksum_field2 != crc32); if (buf_page_is_checksum_valid_none(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
}
return(FALSE);
}
if (buf_page_is_checksum_valid_innodb(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
}
return(FALSE);
}
return(TRUE);
case SRV_CHECKSUM_ALGORITHM_INNODB:
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
return(checksum_field1 if (buf_page_is_checksum_valid_innodb(read_buf,
!= buf_calc_page_new_checksum(read_buf) checksum_field1, checksum_field2)) {
|| checksum_field2 return(FALSE);
!= buf_calc_page_old_checksum(read_buf)); }
if (buf_page_is_checksum_valid_none(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
}
return(FALSE);
}
if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
}
return(FALSE);
}
return(TRUE);
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
return(checksum_field1 != BUF_NO_CHECKSUM_MAGIC if (buf_page_is_checksum_valid_none(read_buf,
|| checksum_field2 != BUF_NO_CHECKSUM_MAGIC); checksum_field1, checksum_field2)) {
return(FALSE);
}
case SRV_CHECKSUM_ALGORITHM_CRC32: if (buf_page_is_checksum_valid_crc32(read_buf,
case SRV_CHECKSUM_ALGORITHM_INNODB: checksum_field1, checksum_field2)) {
/* There are 3 valid formulas for page_warn_strict_checksum(
checksum_field2 (old checksum field): curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
return(FALSE);
}
1. Very old versions of InnoDB only stored 8 byte lsn to the if (buf_page_is_checksum_valid_innodb(read_buf,
start and the end of the page. checksum_field1, checksum_field2)) {
page_warn_strict_checksum(
2. InnoDB versions before MySQL 5.6.3 store the old formula curr_algo,
checksum (buf_calc_page_old_checksum()). SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
3. InnoDB versions 5.6.3 and newer with return(FALSE);
innodb_checksum_algorithm=strict_crc32|crc32 store CRC32. */ }
/* since innodb_checksum_algorithm is not strict_* allow
any of the algos to match for the old field */
if (checksum_field2
!= mach_read_from_4(read_buf + FIL_PAGE_LSN)
&& checksum_field2 != BUF_NO_CHECKSUM_MAGIC) {
/* The checksum does not match any of the
fast to check. First check the selected algorithm
for writing checksums because we assume that the
chance of it matching is higher. */
if (srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_CRC32) {
crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = TRUE;
if (checksum_field2 != crc32
&& checksum_field2
!= buf_calc_page_old_checksum(read_buf)) {
return(TRUE); return(TRUE);
}
} else {
ut_ad(srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_INNODB);
if (checksum_field2
!= buf_calc_page_old_checksum(read_buf)) {
crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = TRUE;
if (checksum_field2 != crc32) {
return(TRUE);
}
}
}
}
/* old field is fine, check the new field */
/* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
(always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
if (checksum_field1 != 0
&& checksum_field1 != BUF_NO_CHECKSUM_MAGIC) {
/* The checksum does not match any of the
fast to check. First check the selected algorithm
for writing checksums because we assume that the
chance of it matching is higher. */
if (srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_CRC32) {
if (!crc32_inited) {
crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = TRUE;
}
if (checksum_field1 != crc32
&& checksum_field1
!= buf_calc_page_new_checksum(read_buf)) {
return(TRUE);
}
} else {
ut_ad(srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_INNODB);
if (checksum_field1
!= buf_calc_page_new_checksum(read_buf)) {
if (!crc32_inited) {
crc32 = buf_calc_page_crc32(
read_buf);
crc32_inited = TRUE;
}
if (checksum_field1 != crc32) {
return(TRUE);
}
}
}
}
/* If CRC32 is stored in at least one of the fields, then the
other field must also be CRC32 */
if (crc32_inited
&& ((checksum_field1 == crc32
&& checksum_field2 != crc32)
|| (checksum_field1 != crc32
&& checksum_field2 == crc32))) {
return(TRUE);
}
break;
case SRV_CHECKSUM_ALGORITHM_NONE: case SRV_CHECKSUM_ALGORITHM_NONE:
/* should have returned FALSE earlier */ /* should have returned FALSE earlier */
ut_error; break;
/* no default so the compiler will emit a warning if new enum /* no default so the compiler will emit a warning if new enum
is added and not handled here */ is added and not handled here */
} }
DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); ); ut_error;
return(FALSE); return(FALSE);
} }
@ -1673,6 +1717,9 @@ page_found:
goto page_found; goto page_found;
} }
/* The maximum number of purge threads should never exceed
BUF_POOL_WATCH_SIZE. So there is no way for purge thread
instance to hold a watch when setting another watch. */
for (i = 0; i < BUF_POOL_WATCH_SIZE; i++) { for (i = 0; i < BUF_POOL_WATCH_SIZE; i++) {
bpage = &buf_pool->watch[i]; bpage = &buf_pool->watch[i];

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -139,14 +139,17 @@ buf_checksum_algorithm_name(
{ {
switch (algo) { switch (algo) {
case SRV_CHECKSUM_ALGORITHM_CRC32: case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
return("crc32"); return("crc32");
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
return("strict_crc32");
case SRV_CHECKSUM_ALGORITHM_INNODB: case SRV_CHECKSUM_ALGORITHM_INNODB:
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
return("innodb"); return("innodb");
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
return("strict_innodb");
case SRV_CHECKSUM_ALGORITHM_NONE: case SRV_CHECKSUM_ALGORITHM_NONE:
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
return("none"); return("none");
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
return("strict_none");
} }
ut_error; ut_error;

View File

@ -498,7 +498,8 @@ ib_cb_t innodb_api_cb[] = {
(ib_cb_t) ib_get_idx_field_name, (ib_cb_t) ib_get_idx_field_name,
(ib_cb_t) ib_trx_get_start_time, (ib_cb_t) ib_trx_get_start_time,
(ib_cb_t) ib_cfg_bk_commit_interval, (ib_cb_t) ib_cfg_bk_commit_interval,
(ib_cb_t) ib_cursor_stmt_begin (ib_cb_t) ib_cursor_stmt_begin,
(ib_cb_t) ib_trx_read_only
}; };
/*************************************************************//** /*************************************************************//**
@ -10945,6 +10946,13 @@ ha_innobase::estimate_rows_upper_bound()
prebuilt->trx->op_info = ""; prebuilt->trx->op_info = "";
/* Set num_rows less than MERGEBUFF to simulate the case where we do
not have enough space to merge the externally sorted file blocks. */
DBUG_EXECUTE_IF("set_num_rows_lt_MERGEBUFF",
estimate = 2;
DBUG_SET("-d,set_num_rows_lt_MERGEBUFF");
);
DBUG_RETURN((ha_rows) estimate); DBUG_RETURN((ha_rows) estimate);
} }
@ -11210,7 +11218,6 @@ ha_innobase::info_low(
dict_table_t* ib_table; dict_table_t* ib_table;
ha_rows rec_per_key; ha_rows rec_per_key;
ib_uint64_t n_rows; ib_uint64_t n_rows;
char path[FN_REFLEN];
os_file_stat_t stat_info; os_file_stat_t stat_info;
DBUG_ENTER("info"); DBUG_ENTER("info");
@ -11268,17 +11275,6 @@ ha_innobase::info_low(
"returning various info to MySQL"; "returning various info to MySQL";
} }
my_snprintf(path, sizeof(path), "%s/%s%s",
mysql_data_home, ib_table->name, reg_ext);
unpack_filename(path,path);
/* Note that we do not know the access time of the table,
nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
if (os_file_get_status(path, &stat_info, false) == DB_SUCCESS) {
stats.create_time = (ulong) stat_info.ctime;
}
} }
if (flag & HA_STATUS_VARIABLE) { if (flag & HA_STATUS_VARIABLE) {
@ -11410,6 +11406,7 @@ ha_innobase::info_low(
if (flag & HA_STATUS_CONST) { if (flag & HA_STATUS_CONST) {
ulong i; ulong i;
char path[FN_REFLEN];
/* Verify the number of index in InnoDB and MySQL /* Verify the number of index in InnoDB and MySQL
matches up. If prebuilt->clust_index_was_generated matches up. If prebuilt->clust_index_was_generated
holds, InnoDB defines GEN_CLUST_INDEX internally */ holds, InnoDB defines GEN_CLUST_INDEX internally */
@ -11563,6 +11560,20 @@ ha_innobase::info_low(
if (!(flag & HA_STATUS_NO_LOCK)) { if (!(flag & HA_STATUS_NO_LOCK)) {
dict_table_stats_unlock(ib_table, RW_S_LATCH); dict_table_stats_unlock(ib_table, RW_S_LATCH);
} }
my_snprintf(path, sizeof(path), "%s/%s%s",
mysql_data_home,
table->s->normalized_path.str,
reg_ext);
unpack_filename(path,path);
/* Note that we do not know the access time of the table,
nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
if (os_file_get_status(path, &stat_info, false) == DB_SUCCESS) {
stats.create_time = (ulong) stat_info.ctime;
}
} }
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2011, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2011, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -494,6 +494,14 @@ ib_trx_state(
/*=========*/ /*=========*/
ib_trx_t ib_trx); /*!< in: trx handle */ ib_trx_t ib_trx); /*!< in: trx handle */
/*****************************************************************//**
Check if the transaction is read_only */
ib_u32_t
ib_trx_read_only(
/*=============*/
ib_trx_t ib_trx); /*!< in: trx handle */
/*****************************************************************//** /*****************************************************************//**
Release the resources of the transaction. If the transaction was Release the resources of the transaction. If the transaction was
selected as a victim by InnoDB and rolled back then use this function selected as a victim by InnoDB and rolled back then use this function

View File

@ -1,6 +1,6 @@
/*********************************************************************** /***********************************************************************
Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc. Copyright (c) 2009, Percona Inc.
Portions of this file contain modifications contributed and copyrighted Portions of this file contain modifications contributed and copyrighted
@ -384,10 +384,10 @@ to original un-instrumented file I/O APIs */
enum os_file_type_t { enum os_file_type_t {
OS_FILE_TYPE_UNKNOWN = 0, OS_FILE_TYPE_UNKNOWN = 0,
OS_FILE_TYPE_FILE, /* regular file */ OS_FILE_TYPE_FILE, /* regular file
(or a character/block device) */
OS_FILE_TYPE_DIR, /* directory */ OS_FILE_TYPE_DIR, /* directory */
OS_FILE_TYPE_LINK, /* symbolic link */ OS_FILE_TYPE_LINK /* symbolic link */
OS_FILE_TYPE_BLOCK /* block device */
}; };
/* Maximum path string length in bytes when referring to tables with in the /* Maximum path string length in bytes when referring to tables with in the

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -1121,6 +1121,20 @@ page_find_rec_with_heap_no(
const rec_t* const rec_t*
page_find_rec_max_not_deleted( page_find_rec_max_not_deleted(
const page_t* page); const page_t* page);
/** Issue a warning when the checksum that is stored in the page is valid,
but different than the global setting innodb_checksum_algorithm.
@param[in] current_algo current checksum algorithm
@param[in] page_checksum page valid checksum
@param[in] space_id tablespace id
@param[in] page_no page number */
void
page_warn_strict_checksum(
srv_checksum_algorithm_t curr_algo,
srv_checksum_algorithm_t page_checksum,
ulint space_id,
ulint page_no);
#ifdef UNIV_MATERIALIZE #ifdef UNIV_MATERIALIZE
#undef UNIV_INLINE #undef UNIV_INLINE
#define UNIV_INLINE UNIV_INLINE_ORIGINAL #define UNIV_INLINE UNIV_INLINE_ORIGINAL

View File

@ -44,7 +44,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MAJOR 5
#define INNODB_VERSION_MINOR 6 #define INNODB_VERSION_MINOR 6
#define INNODB_VERSION_BUGFIX 24 #define INNODB_VERSION_BUGFIX 25
/* The following is the InnoDB version as shown in /* The following is the InnoDB version as shown in
SELECT plugin_version FROM information_schema.plugins; SELECT plugin_version FROM information_schema.plugins;

View File

@ -1,6 +1,6 @@
/*********************************************************************** /***********************************************************************
Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Percona Inc. Copyright (c) 2009, Percona Inc.
Portions of this file contain modifications contributed and copyrighted Portions of this file contain modifications contributed and copyrighted
@ -3217,8 +3217,9 @@ os_file_get_status(
stat_info->type = OS_FILE_TYPE_LINK; stat_info->type = OS_FILE_TYPE_LINK;
break; break;
case S_IFBLK: case S_IFBLK:
stat_info->type = OS_FILE_TYPE_BLOCK; /* Handle block device as regular file. */
break; case S_IFCHR:
/* Handle character device as regular file. */
case S_IFREG: case S_IFREG:
stat_info->type = OS_FILE_TYPE_FILE; stat_info->type = OS_FILE_TYPE_FILE;
break; break;
@ -3227,8 +3228,8 @@ os_file_get_status(
} }
if (check_rw_perm && (stat_info->type == OS_FILE_TYPE_FILE if (check_rw_perm && stat_info->type == OS_FILE_TYPE_FILE) {
|| stat_info->type == OS_FILE_TYPE_BLOCK)) {
int fh; int fh;
int access; int access;

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
@ -2811,3 +2811,45 @@ page_find_rec_max_not_deleted(
} }
return(prev_rec); return(prev_rec);
} }
/** Issue a warning when the checksum that is stored in the page is valid,
but different than the global setting innodb_checksum_algorithm.
@param[in] current_algo current checksum algorithm
@param[in] page_checksum page valid checksum
@param[in] space_id tablespace id
@param[in] page_no page number */
void
page_warn_strict_checksum(
srv_checksum_algorithm_t curr_algo,
srv_checksum_algorithm_t page_checksum,
ulint space_id,
ulint page_no)
{
srv_checksum_algorithm_t curr_algo_nonstrict;
switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_CRC32;
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_INNODB;
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_NONE;
break;
default:
ut_error;
}
ib_logf(IB_LOG_LEVEL_WARN,
"innodb_checksum_algorithm is set to \"%s\""
" but the page [page id: space=" ULINTPF ","
" page number=" ULINTPF "] contains a valid checksum \"%s\"."
" Accepting the page as valid. Change innodb_checksum_algorithm"
" to \"%s\" to silently accept such pages or rewrite all pages"
" so that they contain \"%s\" checksum.",
buf_checksum_algorithm_name(curr_algo),
space_id, page_no,
buf_checksum_algorithm_name(page_checksum),
buf_checksum_algorithm_name(curr_algo_nonstrict),
buf_checksum_algorithm_name(curr_algo_nonstrict));
}

View File

@ -4926,6 +4926,10 @@ page_zip_verify_checksum(
stored = static_cast<ib_uint32_t>(mach_read_from_4( stored = static_cast<ib_uint32_t>(mach_read_from_4(
static_cast<const unsigned char*>(data) + FIL_PAGE_SPACE_OR_CHKSUM)); static_cast<const unsigned char*>(data) + FIL_PAGE_SPACE_OR_CHKSUM));
ulint page_no = mach_read_from_4(static_cast<const unsigned char*> (data) + FIL_PAGE_OFFSET);
ulint space_id = mach_read_from_4(static_cast<const unsigned char*>
(data) + FIL_PAGE_SPACE_ID);
#if FIL_PAGE_LSN % 8 #if FIL_PAGE_LSN % 8
#error "FIL_PAGE_LSN must be 64 bit aligned" #error "FIL_PAGE_LSN must be 64 bit aligned"
#endif #endif
@ -4951,40 +4955,113 @@ page_zip_verify_checksum(
} }
#endif #endif
const srv_checksum_algorithm_t curr_algo =
static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
if (curr_algo == SRV_CHECKSUM_ALGORITHM_NONE) {
return(TRUE);
}
calc = static_cast<ib_uint32_t>(page_zip_calc_checksum( calc = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, static_cast<srv_checksum_algorithm_t>( data, size, curr_algo));
srv_checksum_algorithm)));
if (stored == calc) { if (stored == calc) {
return(TRUE); return(TRUE);
} }
switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) { switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
return(stored == calc);
case SRV_CHECKSUM_ALGORITHM_CRC32: case SRV_CHECKSUM_ALGORITHM_CRC32:
if (stored == BUF_NO_CHECKSUM_MAGIC) { if (stored == BUF_NO_CHECKSUM_MAGIC) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
}
return(TRUE); return(TRUE);
} }
crc32 = calc;
innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum( innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_INNODB)); data, size, SRV_CHECKSUM_ALGORITHM_INNODB));
break;
case SRV_CHECKSUM_ALGORITHM_INNODB: if (stored == innodb) {
if (stored == BUF_NO_CHECKSUM_MAGIC) { if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
}
return(TRUE); return(TRUE);
} }
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
case SRV_CHECKSUM_ALGORITHM_INNODB:
if (stored == BUF_NO_CHECKSUM_MAGIC) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
}
return(TRUE);
}
crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum( crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32)); data, size, SRV_CHECKSUM_ALGORITHM_CRC32));
innodb = calc;
if (stored == crc32) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
}
return(TRUE);
}
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32));
if (stored == crc32) {
page_warn_strict_checksum(
curr_algo, SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
return(TRUE);
}
innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_INNODB));
if (stored == innodb) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
return(TRUE);
}
break; break;
case SRV_CHECKSUM_ALGORITHM_NONE: case SRV_CHECKSUM_ALGORITHM_NONE:
return(TRUE); ut_error;
/* no default so the compiler will emit a warning if new enum /* no default so the compiler will emit a warning if new enum
is added and not handled here */ is added and not handled here */
} }
return(stored == crc32 || stored == innodb); return(FALSE);
} }

View File

@ -1325,19 +1325,15 @@ row_insert_for_mysql(
mem_analyze_corruption(prebuilt); mem_analyze_corruption(prebuilt);
ut_error; ut_error;
} else if (srv_created_new_raw || srv_force_recovery) { } else if (srv_force_recovery) {
fputs("InnoDB: A new raw disk partition was initialized or\n" fputs("InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: database modifications by the user. Shut down\n" "InnoDB: database modifications by the user. Shut down\n"
"InnoDB: mysqld and edit my.cnf so that" "InnoDB: mysqld and edit my.cnf so that"
" newraw is replaced\n" "InnoDB: innodb_force_... is removed.\n",
"InnoDB: with raw, and innodb_force_... is removed.\n",
stderr); stderr);
if(srv_force_recovery) {
return(DB_READ_ONLY); return(DB_READ_ONLY);
} }
return(DB_ERROR);
}
trx->op_info = "inserting"; trx->op_info = "inserting";
@ -1727,19 +1723,15 @@ row_update_for_mysql(
ut_error; ut_error;
} }
if (UNIV_UNLIKELY(srv_created_new_raw || srv_force_recovery)) { if (UNIV_UNLIKELY(srv_force_recovery)) {
fputs("InnoDB: A new raw disk partition was initialized or\n" fputs("InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: database modifications by the user. Shut down\n" "InnoDB: database modifications by the user. Shut down\n"
"InnoDB: mysqld and edit my.cnf so that newraw" "InnoDB: mysqld and edit my.cnf so that"
" is replaced\n" "InnoDB: innodb_force_... is removed.\n",
"InnoDB: with raw, and innodb_force_... is removed.\n",
stderr); stderr);
if(srv_force_recovery) {
return(DB_READ_ONLY); return(DB_READ_ONLY);
} }
return(DB_ERROR);
}
DEBUG_SYNC_C("innodb_row_update_for_mysql_begin"); DEBUG_SYNC_C("innodb_row_update_for_mysql_begin");
@ -2237,22 +2229,6 @@ row_create_table_for_mysql(
goto err_exit; goto err_exit;
); );
if (srv_created_new_raw) {
fputs("InnoDB: A new raw disk partition was initialized:\n"
"InnoDB: we do not allow database modifications"
" by the user.\n"
"InnoDB: Shut down mysqld and edit my.cnf so that newraw"
" is replaced with raw.\n", stderr);
err_exit:
dict_mem_table_free(table);
if (commit) {
trx_commit_for_mysql(trx);
}
return(DB_ERROR);
}
trx->op_info = "creating table"; trx->op_info = "creating table";
if (row_mysql_is_system_table(table->name)) { if (row_mysql_is_system_table(table->name)) {
@ -2263,7 +2239,19 @@ err_exit:
"InnoDB: MySQL system tables must be" "InnoDB: MySQL system tables must be"
" of the MyISAM type!\n", " of the MyISAM type!\n",
table->name); table->name);
goto err_exit;
#ifndef DBUG_OFF
err_exit:
#endif /* !DBUG_OFF */
dict_mem_table_free(table);
if (commit) {
trx_commit_for_mysql(trx);
}
trx->op_info = "";
return(DB_ERROR);
} }
trx_start_if_not_started_xa(trx); trx_start_if_not_started_xa(trx);
@ -3313,16 +3301,6 @@ row_truncate_table_for_mysql(
ut_ad(table); ut_ad(table);
if (srv_created_new_raw) {
fputs("InnoDB: A new raw disk partition was initialized:\n"
"InnoDB: we do not allow database modifications"
" by the user.\n"
"InnoDB: Shut down mysqld and edit my.cnf so that newraw"
" is replaced with raw.\n", stderr);
return(DB_ERROR);
}
if (dict_table_is_discarded(table)) { if (dict_table_is_discarded(table)) {
return(DB_TABLESPACE_DELETED); return(DB_TABLESPACE_DELETED);
} else if (table->ibd_file_missing) { } else if (table->ibd_file_missing) {
@ -3802,16 +3780,6 @@ row_drop_table_for_mysql(
ut_a(name != NULL); ut_a(name != NULL);
if (srv_created_new_raw) {
fputs("InnoDB: A new raw disk partition was initialized:\n"
"InnoDB: we do not allow database modifications"
" by the user.\n"
"InnoDB: Shut down mysqld and edit my.cnf so that newraw"
" is replaced with raw.\n", stderr);
DBUG_RETURN(DB_ERROR);
}
/* The table name is prefixed with the database name and a '/'. /* The table name is prefixed with the database name and a '/'.
Certain table names starting with 'innodb_' have their special Certain table names starting with 'innodb_' have their special
meaning regardless of the database name. Thus, we need to meaning regardless of the database name. Thus, we need to
@ -4824,19 +4792,16 @@ row_rename_table_for_mysql(
ut_a(new_name != NULL); ut_a(new_name != NULL);
ut_ad(trx->state == TRX_STATE_ACTIVE); ut_ad(trx->state == TRX_STATE_ACTIVE);
if (srv_created_new_raw || srv_force_recovery) { if (srv_force_recovery) {
fputs("InnoDB: A new raw disk partition was initialized or\n" fputs("InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: innodb_force_recovery is on: we do not allow\n"
"InnoDB: database modifications by the user. Shut down\n" "InnoDB: database modifications by the user. Shut down\n"
"InnoDB: mysqld and edit my.cnf so that newraw" "InnoDB: mysqld and edit my.cnf so that"
" is replaced\n" "InnoDB: innodb_force_... is removed.\n",
"InnoDB: with raw, and innodb_force_... is removed.\n",
stderr); stderr);
if(srv_force_recovery) {
err = DB_READ_ONLY;
}
err = DB_READ_ONLY;
goto funct_exit; goto funct_exit;
} else if (row_mysql_is_system_table(new_name)) { } else if (row_mysql_is_system_table(new_name)) {
fprintf(stderr, fprintf(stderr,

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, Google Inc. Copyright (c) 2008, Google Inc.
Copyright (c) 2009, Percona Inc. Copyright (c) 2009, Percona Inc.
@ -233,8 +233,8 @@ srv_file_check_mode(
/* Note: stat.rw_perm is only valid of files */ /* Note: stat.rw_perm is only valid of files */
if (stat.type == OS_FILE_TYPE_FILE if (stat.type == OS_FILE_TYPE_FILE) {
|| stat.type == OS_FILE_TYPE_BLOCK) {
if (!stat.rw_perm) { if (!stat.rw_perm) {
ib_logf(IB_LOG_LEVEL_ERROR, ib_logf(IB_LOG_LEVEL_ERROR,
@ -431,14 +431,18 @@ srv_parse_data_file_paths_and_sizes(
&& *(str + 1) == 'e' && *(str + 1) == 'e'
&& *(str + 2) == 'w') { && *(str + 2) == 'w') {
str += 3; str += 3;
(srv_data_file_is_raw_partition)[i] = SRV_NEW_RAW; /* Initialize new raw device only during bootstrap */
(srv_data_file_is_raw_partition)[i] =
opt_bootstrap ? SRV_NEW_RAW : SRV_OLD_RAW;
} }
if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') { if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
str += 3; str += 3;
/* Initialize new raw device only during bootstrap */
if ((srv_data_file_is_raw_partition)[i] == 0) { if ((srv_data_file_is_raw_partition)[i] == 0) {
(srv_data_file_is_raw_partition)[i] = SRV_OLD_RAW; (srv_data_file_is_raw_partition)[i] =
opt_bootstrap ? SRV_NEW_RAW : SRV_OLD_RAW;
} }
} }
@ -891,6 +895,24 @@ open_or_create_data_files(
return(DB_ERROR); return(DB_ERROR);
} }
const char* check_msg;
check_msg = fil_read_first_page(
files[i], FALSE, &flags, &space,
#ifdef UNIV_LOG_ARCHIVE
min_arch_log_no, max_arch_log_no,
#endif /* UNIV_LOG_ARCHIVE */
min_flushed_lsn, max_flushed_lsn);
/* If first page is valid, don't overwrite DB.
It prevents overwriting DB when mysql_install_db
starts mysqld multiple times during bootstrap. */
if (check_msg == NULL) {
srv_created_new_raw = FALSE;
ret = FALSE;
}
} else if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) { } else if (srv_data_file_is_raw_partition[i] == SRV_OLD_RAW) {
srv_start_raw_disk_in_use = TRUE; srv_start_raw_disk_in_use = TRUE;
@ -3088,9 +3110,9 @@ innobase_shutdown_for_mysql(void)
ibuf_close(); ibuf_close();
log_shutdown(); log_shutdown();
lock_sys_close();
trx_sys_file_format_close(); trx_sys_file_format_close();
trx_sys_close(); trx_sys_close();
lock_sys_close();
/* We don't create these mutexes in RO mode because we don't create /* We don't create these mutexes in RO mode because we don't create
the temp files that the cover. */ the temp files that the cover. */

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1995, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc. Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
@ -1101,8 +1101,8 @@ sync_array_print_info_low(
os_thread_id_t r = 0; os_thread_id_t r = 0;
fprintf(file, fprintf(file,
"OS WAIT ARRAY INFO: reservation count %ld\n", "OS WAIT ARRAY INFO: reservation count " ULINTPF "\n",
(long) arr->res_count); arr->res_count);
for (i = 0; count < arr->n_reserved; ++i) { for (i = 0; count < arr->n_reserved; ++i) {
sync_cell_t* cell; sync_cell_t* cell;
@ -1197,7 +1197,7 @@ sync_array_print(
} }
fprintf(file, fprintf(file,
"OS WAIT ARRAY INFO: signal count %ld\n", (long) sg_count); "OS WAIT ARRAY INFO: signal count " ULINTPF "\n", sg_count);
} }

View File

@ -1187,8 +1187,6 @@ trx_sys_close(void)
/* Free the double write data structures. */ /* Free the double write data structures. */
buf_dblwr_free(); buf_dblwr_free();
mutex_enter(&trx_sys->mutex);
ut_a(UT_LIST_GET_LEN(trx_sys->ro_trx_list) == 0); ut_a(UT_LIST_GET_LEN(trx_sys->ro_trx_list) == 0);
/* Only prepared transactions may be left in the system. Free them. */ /* Only prepared transactions may be left in the system. Free them. */
@ -1228,8 +1226,6 @@ trx_sys_close(void)
ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == 0); ut_a(UT_LIST_GET_LEN(trx_sys->rw_trx_list) == 0);
ut_a(UT_LIST_GET_LEN(trx_sys->mysql_trx_list) == 0); ut_a(UT_LIST_GET_LEN(trx_sys->mysql_trx_list) == 0);
mutex_exit(&trx_sys->mutex);
mutex_free(&trx_sys->mutex); mutex_free(&trx_sys->mutex);
mem_free(trx_sys); mem_free(trx_sys);

View File

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -307,11 +307,10 @@ trx_free_prepared(
/*==============*/ /*==============*/
trx_t* trx) /*!< in, own: trx object */ trx_t* trx) /*!< in, own: trx object */
{ {
ut_ad(mutex_own(&trx_sys->mutex));
ut_a(trx_state_eq(trx, TRX_STATE_PREPARED)); ut_a(trx_state_eq(trx, TRX_STATE_PREPARED));
ut_a(trx->magic_n == TRX_MAGIC_N); ut_a(trx->magic_n == TRX_MAGIC_N);
lock_trx_release_locks(trx);
trx_undo_free_prepared(trx); trx_undo_free_prepared(trx);
assert_trx_in_rw_list(trx); assert_trx_in_rw_list(trx);