lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit 4f479fb1 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'merge-xtradb-5.6' into 10.0

XtraDB 5.6.25-73.1
parents 772c3f37 0b3eb455
......@@ -595,6 +595,21 @@ ib_trx_begin(
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.
@return transaction state */
......
/*****************************************************************************
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.
Portions of this file contain modifications contributed and copyrighted by
......@@ -555,6 +555,79 @@ buf_page_is_zeroes(
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.
@return TRUE if corrupted */
......@@ -570,8 +643,6 @@ buf_page_is_corrupted(
{
ulint checksum_field1;
ulint checksum_field2;
ibool crc32_inited = FALSE;
ib_uint32_t crc32 = ULINT32_UNDEFINED;
if (!zip_size
&& memcmp(read_buf + FIL_PAGE_LSN + 4,
......@@ -651,148 +722,121 @@ buf_page_is_corrupted(
return(FALSE);
}
switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
crc32 = buf_calc_page_crc32(read_buf);
return(checksum_field1 != crc32 || checksum_field2 != crc32);
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
return(checksum_field1
!= buf_calc_page_new_checksum(read_buf)
|| checksum_field2
!= buf_calc_page_old_checksum(read_buf));
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); );
return(checksum_field1 != BUF_NO_CHECKSUM_MAGIC
|| checksum_field2 != BUF_NO_CHECKSUM_MAGIC);
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_INNODB:
/* There are 3 valid formulas for
checksum_field2 (old checksum field):
1. Very old versions of InnoDB only stored 8 byte lsn to the
start and the end of the page.
2. InnoDB versions before MySQL 5.6.3 store the old formula
checksum (buf_calc_page_old_checksum()).
3. InnoDB versions 5.6.3 and newer with
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)) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
return(TRUE);
}
} else {
ut_ad(srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_INNODB);
if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2)) {
return(FALSE);
}
if (checksum_field2
!= 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_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
}
crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = TRUE;
return(FALSE);
}
if (checksum_field2 != crc32) {
return(TRUE);
}
}
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);
}
}
/* old field is fine, check the new field */
return(FALSE);
}
/* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
(always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
return(TRUE);
if (checksum_field1 != 0
&& checksum_field1 != BUF_NO_CHECKSUM_MAGIC) {
case SRV_CHECKSUM_ALGORITHM_INNODB:
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
/* 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 (buf_page_is_checksum_valid_innodb(read_buf,
checksum_field1, checksum_field2)) {
return(FALSE);
}
if (srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_CRC32) {
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);
}
if (!crc32_inited) {
crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = TRUE;
}
return(FALSE);
}
if (checksum_field1 != crc32
&& checksum_field1
!= buf_calc_page_new_checksum(read_buf)) {
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(TRUE);
}
} else {
ut_ad(srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_INNODB);
return(FALSE);
}
if (checksum_field1
!= buf_calc_page_new_checksum(read_buf)) {
return(TRUE);
if (!crc32_inited) {
crc32 = buf_calc_page_crc32(
read_buf);
crc32_inited = TRUE;
}
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
if (checksum_field1 != crc32) {
return(TRUE);
}
}
}
if (buf_page_is_checksum_valid_none(read_buf,
checksum_field1, checksum_field2)) {
return(FALSE);
}
/* 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))) {
if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2)) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
return(FALSE);
}
return(TRUE);
if (buf_page_is_checksum_valid_innodb(read_buf,
checksum_field1, checksum_field2)) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
return(FALSE);
}
break;
return(TRUE);
case SRV_CHECKSUM_ALGORITHM_NONE:
/* should have returned FALSE earlier */
ut_error;
break;
/* no default so the compiler will emit a warning if new enum
is added and not handled here */
}
DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); );
ut_error;
return(FALSE);
}
......@@ -1762,6 +1806,9 @@ buf_pool_watch_set(
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++) {
bpage = &buf_pool->watch[i];
......
/*****************************************************************************
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
the terms of the GNU General Public License as published by the Free Software
......@@ -27,11 +27,13 @@ Created Aug 11, 2011 Vasil Dimov
#include "fil0fil.h" /* FIL_* */
#include "ut0crc32.h" /* ut_crc32() */
#include "ut0rnd.h" /* ut_fold_binary() */
#include "buf0types.h"
#ifndef UNIV_INNOCHECKSUM
#include "srv0srv.h" /* SRV_CHECKSUM_* */
#include "buf0types.h"
#endif /* !UNIV_INNOCHECKSUM */
/** the macro MYSQL_SYSVAR_ENUM() requires "long unsigned int" and if we
use srv_checksum_algorithm_t here then we get a compiler error:
......@@ -39,8 +41,6 @@ ha_innodb.cc:12251: error: cannot convert 'srv_checksum_algorithm_t*' to
'long unsigned int*' in initialization */
UNIV_INTERN ulong srv_checksum_algorithm = SRV_CHECKSUM_ALGORITHM_INNODB;
#endif /* !UNIV_INNOCHECKSUM */
/********************************************************************//**
Calculates a page CRC32 which is stored to the page when it is written
to a file. Note that we must be careful to calculate the same value on
......@@ -125,8 +125,6 @@ buf_calc_page_old_checksum(
return(checksum);
}
#ifndef UNIV_INNOCHECKSUM
/********************************************************************//**
Return a printable string describing the checksum algorithm.
@return algorithm name */
......@@ -138,18 +136,19 @@ buf_checksum_algorithm_name(
{
switch (algo) {
case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
return("crc32");
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
return("strict_crc32");
case SRV_CHECKSUM_ALGORITHM_INNODB:
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
return("innodb");
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
return("strict_innodb");
case SRV_CHECKSUM_ALGORITHM_NONE:
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
return("none");
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
return("strict_none");
}
ut_error;
return(NULL);
}
#endif /* !UNIV_INNOCHECKSUM */
......@@ -932,11 +932,11 @@ buf_flush_write_block_low(
case BUF_BLOCK_ZIP_DIRTY:
frame = bpage->zip.data;
ut_a(page_zip_verify_checksum(frame, zip_size));
mach_write_to_8(frame + FIL_PAGE_LSN,
bpage->newest_modification);
memset(frame + FIL_PAGE_FILE_FLUSH_LSN, 0, 8);
ut_a(page_zip_verify_checksum(frame, zip_size));
break;
case BUF_BLOCK_FILE_PAGE:
frame = bpage->zip.data;
......
......@@ -559,7 +559,8 @@ ib_cb_t innodb_api_cb[] = {
(ib_cb_t) ib_get_idx_field_name,
(ib_cb_t) ib_trx_get_start_time,
(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
};
/*************************************************************//**
......@@ -11609,6 +11610,13 @@ ha_innobase::estimate_rows_upper_bound()
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);
}
......@@ -11874,7 +11882,6 @@ ha_innobase::info_low(
dict_table_t* ib_table;
ha_rows rec_per_key;
ib_uint64_t n_rows;
char path[FN_REFLEN];
os_file_stat_t stat_info;
DBUG_ENTER("info");
......@@ -11931,6 +11938,7 @@ ha_innobase::info_low(
prebuilt->trx->op_info =
"returning various info to MySQL";
}
}
if (flag & HA_STATUS_VARIABLE) {
......@@ -12062,6 +12070,7 @@ ha_innobase::info_low(
if (flag & HA_STATUS_CONST) {
ulong i;
char path[FN_REFLEN];
/* Verify the number of index in InnoDB and MySQL
matches up. If prebuilt->clust_index_was_generated
holds, InnoDB defines GEN_CLUST_INDEX internally */
......
/*****************************************************************************
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
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 */
/*****************************************************************//**
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
selected as a victim by InnoDB and rolled back then use this function
......
......@@ -96,9 +96,6 @@ extern buf_block_t* back_block1; /*!< first block, for --apply-log */
extern buf_block_t* back_block2; /*!< second block, for page reorganize */
#endif /* !UNIV_HOTBACKUP */
/** Magic value to use instead of checksums when they are disabled */
#define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
/** @brief States of a control block
@see buf_page_t
......
......@@ -28,11 +28,10 @@ Created Aug 11, 2011 Vasil Dimov
#include "univ.i"
#ifndef UNIV_INNOCHECKSUM
#include "buf0types.h"
#endif /* !UNIV_INNOCHECKSUM */
/** Magic value to use instead of checksums when they are disabled */
#define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
/********************************************************************//**
Calculates a page CRC32 which is stored to the page when it is written
......@@ -70,8 +69,6 @@ buf_calc_page_old_checksum(
/*=======================*/
const byte* page); /*!< in: buffer page */
#ifndef UNIV_INNOCHECKSUM
/********************************************************************//**
Return a printable string describing the checksum algorithm.
@return algorithm name */
......@@ -83,6 +80,4 @@ buf_checksum_algorithm_name(
extern ulong srv_checksum_algorithm;
#endif /* !UNIV_INNOCHECKSUM */
#endif /* buf0checksum_h */
......@@ -28,7 +28,9 @@ Created 11/5/1995 Heikki Tuuri
#include "univ.i"
#ifndef UNIV_HOTBACKUP
#ifndef UNIV_INNOCHECKSUM
#include "ut0byte.h"
#endif
#include "buf0types.h"
// Forward declaration
......
......@@ -28,14 +28,17 @@ Created 5/11/2006 Osku Salerma
#define HA_INNODB_PROTOTYPES_H
#include "my_dbug.h"
#include "mysqld_error.h"
#include "my_compare.h"
#include "my_sys.h"
#include "m_string.h"
#include "debug_sync.h"
#include "my_base.h"
#ifndef UNIV_INNOCHECKSUM
#include "mysqld_error.h"
#include "debug_sync.h"
#include "trx0types.h"
#endif
#include "m_ctype.h" /* CHARSET_INFO */
// Forward declarations
......@@ -81,6 +84,8 @@ innobase_raw_format(
ulint buf_size); /*!< in: output buffer size
in bytes */
#ifndef UNIV_INNOCHECKSUM
/*****************************************************************//**
Invalidates the MySQL query cache for the table. */
UNIV_INTERN
......@@ -97,6 +102,8 @@ innobase_invalidate_query_cache(
ulint full_name_len); /*!< in: full name length where
also the null chars count */
#endif /* #ifndef UNIV_INNOCHECKSUM */
/*****************************************************************//**
Convert a table or index name to the MySQL system_charset_info (UTF-8)
and quote it if needed.
......
/*****************************************************************************
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
the terms of the GNU General Public License as published by the Free Software
......@@ -28,6 +28,10 @@ Created 2/2/1994 Heikki Tuuri
#include "univ.i"
#include "buf0types.h"
#ifndef UNIV_INNOCHECKSUM
#include "page0types.h"
#include "fil0fil.h"
#include "buf0buf.h"
......@@ -1110,6 +1114,24 @@ page_find_rec_with_heap_no(
const rec_t*
page_find_rec_max_not_deleted(
const page_t* page);
#endif /* #ifndef UNIV_INNOCHECKSUM */
/** 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);
#ifndef UNIV_INNOCHECKSUM
#ifdef UNIV_MATERIALIZE
#undef UNIV_INLINE
#define UNIV_INLINE UNIV_INLINE_ORIGINAL
......@@ -1119,4 +1141,6 @@ page_find_rec_max_not_deleted(
#include "page0page.ic"
#endif
#endif /* #ifndef UNIV_INNOCHECKSUM */
#endif
......@@ -107,6 +107,8 @@ struct page_zip_stat_t {
{ }
};
#ifndef UNIV_INNOCHECKSUM
/** Compression statistics types */
typedef map<index_id_t, page_zip_stat_t> page_zip_stat_per_index_t;
......@@ -119,6 +121,8 @@ extern ib_mutex_t page_zip_stat_per_index_mutex;
extern mysql_pfs_key_t page_zip_stat_per_index_mutex_key;
#endif /* HAVE_PSI_INTERFACE */
#endif /* !UNIV_INNOCHECKSUM */
/**********************************************************************//**
Write the "deleted" flag of a record on a compressed page. The flag must
already have been written on the uncompressed page. */
......
......@@ -32,13 +32,17 @@ Created June 2005 by Marko Makela
# define UNIV_INLINE
#endif
#include "mtr0types.h"
#ifndef UNIV_INNOCHECKSUM
#include "page0types.h"
#include "buf0types.h"
#include "mtr0types.h"
#include "dict0types.h"
#include "srv0srv.h"
#include "trx0types.h"
#include "mem0mem.h"
#else
#include "univ.i"
#endif /* !UNIV_INNOCHECKSUM */
#include "buf0types.h"
/* Compression level to be used by zlib. Settable by user. */
extern uint page_zip_level;
......@@ -50,6 +54,7 @@ extern uint page_zip_level;
compression algorithm changes in zlib. */
extern my_bool page_zip_log_pages;
#ifndef UNIV_INNOCHECKSUM
/**********************************************************************//**
Determine the size of a compressed page in bytes.
@return size in bytes */
......@@ -159,6 +164,8 @@ page_zip_simple_validate(
descriptor */
#endif /* UNIV_DEBUG */
#endif /* !UNIV_INNOCHECKSUM */
#ifdef UNIV_ZIP_DEBUG
/**********************************************************************//**
Check that the compressed and decompressed pages match.
......@@ -185,6 +192,7 @@ page_zip_validate(
__attribute__((nonnull(1,2)));
#endif /* UNIV_ZIP_DEBUG */
#ifndef UNIV_INNOCHECKSUM
/**********************************************************************//**
Determine how big record can be inserted without recompressing the page.
@return a positive number indicating the maximum size of a record
......@@ -452,6 +460,8 @@ page_zip_parse_compress(
page_zip_des_t* page_zip)/*!< out: compressed page */
__attribute__((nonnull(1,2)));
#endif /* !UNIV_INNOCHECKSUM */
/**********************************************************************//**
Calculate the compressed page checksum.
@return page checksum */
......@@ -474,6 +484,9 @@ page_zip_verify_checksum(
/*=====================*/
const void* data, /*!< in: compressed page */
ulint size); /*!< in: size of compressed page */
#ifndef UNIV_INNOCHECKSUM
/**********************************************************************//**
Write a log record of compressing an index page without the data on the page. */
UNIV_INLINE
......@@ -506,6 +519,8 @@ void
page_zip_reset_stat_per_index();
/*===========================*/
#endif /* !UNIV_INNOCHECKSUM */
#ifndef UNIV_HOTBACKUP
/** Check if a pointer to an uncompressed page matches a compressed page.
When we IMPORT a tablespace the blocks and accompanying frames are allocted
......@@ -531,8 +546,10 @@ from outside the buffer pool.
# define UNIV_INLINE UNIV_INLINE_ORIGINAL
#endif
#ifndef UNIV_INNOCHECKSUM
#ifndef UNIV_NONINL
# include "page0zip.ic"
#endif
#endif /* !UNIV_INNOCHECKSUM */
#endif /* page0zip_h */
......@@ -436,7 +436,6 @@ extern ibool srv_use_atomic_writes;
#ifdef HAVE_POSIX_FALLOCATE
extern ibool srv_use_posix_fallocate;
#endif
extern ulong srv_checksum_algorithm;
extern ulong srv_log_arch_expire_sec;
......
......@@ -44,10 +44,10 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 5
#define INNODB_VERSION_MINOR 6
#define INNODB_VERSION_BUGFIX 24
#define INNODB_VERSION_BUGFIX 25
#ifndef PERCONA_INNODB_VERSION
#define PERCONA_INNODB_VERSION 72.2
#define PERCONA_INNODB_VERSION 73.1
#endif
/* Enable UNIV_LOG_ARCHIVE in XtraDB */
......
......@@ -2725,7 +2725,8 @@ lock_rec_inherit_to_gap(
&& !((srv_locks_unsafe_for_binlog
|| lock->trx->isolation_level
<= TRX_ISO_READ_COMMITTED)
&& lock_get_mode(lock) == LOCK_X)) {
&& lock_get_mode(lock) ==
(lock->trx->duplicates ? LOCK_S : LOCK_X))) {
lock_rec_add_to_queue(
LOCK_REC | LOCK_GAP | lock_get_mode(lock),
......
/*****************************************************************************
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.
This program is free software; you can redistribute it and/or modify it under
......@@ -31,6 +31,11 @@ Created 2/2/1994 Heikki Tuuri
#endif
#undef THIS_MODULE
#include "ha_prototypes.h"
#include "buf0checksum.h"
#ifndef UNIV_INNOCHECKSUM
#include "page0cur.h"
#include "page0zip.h"
#include "buf0buf.h"
......@@ -2811,3 +2816,51 @@ page_find_rec_max_not_deleted(
}
return(prev_rec);
}
#endif /* #ifndef UNIV_INNOCHECKSUM */
/** 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;
}
#ifdef UNIV_INNOCHECKSUM
fprintf(stderr,
#else
ib_logf(IB_LOG_LEVEL_WARN,
#endif
"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));
}
......@@ -37,30 +37,40 @@ using namespace std;
# include "page0zip.ic"
#endif
#undef THIS_MODULE
#include "buf0checksum.h"
#include "page0page.h"
#ifndef UNIV_INNOCHECKSUM
#include "mtr0log.h"
#include "ut0sort.h"
#include "dict0dict.h"
#include "btr0cur.h"
#include "page0types.h"
#include "log0recv.h"
#endif /* !UNIV_INNOCHECKSUM */
#include "zlib.h"
#include "fil0fil.h"
#include "ut0sort.h"
#include "page0types.h"
#ifndef UNIV_HOTBACKUP
#ifndef UNIV_INNOCHECKSUM
# include "buf0buf.h"
# include "buf0lru.h"
# include "btr0sea.h"
# include "dict0boot.h"
# include "lock0lock.h"
# include "srv0mon.h"
# include "srv0srv.h"
#endif /* !UNIV_INNOCHECKSUM */
# include "buf0lru.h"
# include "ut0crc32.h"
#else /* !UNIV_HOTBACKUP */
# include "buf0checksum.h"
# define lock_move_reorganize_page(block, temp_block) ((void) 0)
# define buf_LRU_stat_inc_unzip() ((void) 0)
#endif /* !UNIV_HOTBACKUP */
#ifdef UNIV_INNOCHECKSUM
#include "mach0data.h"
#endif /* UNIV_INNOCHECKSUM */
#ifndef UNIV_HOTBACKUP
#ifndef UNIV_INNOCHECKSUM
/** Statistics on compression, indexed by page_zip_des_t::ssize - 1 */
UNIV_INTERN page_zip_stat_t page_zip_stat[PAGE_ZIP_SSIZE_MAX];
/** Statistics on compression, indexed by index->id */
......@@ -70,6 +80,7 @@ UNIV_INTERN ib_mutex_t page_zip_stat_per_index_mutex;
#ifdef HAVE_PSI_INTERFACE
UNIV_INTERN mysql_pfs_key_t page_zip_stat_per_index_mutex_key;
#endif /* HAVE_PSI_INTERFACE */
#endif /* !UNIV_INNOCHECKSUM */
#endif /* !UNIV_HOTBACKUP */
/* Compression level to be used by zlib. Settable by user. */
......@@ -82,6 +93,8 @@ UNIV_INTERN my_bool page_zip_log_pages = true;
/* Please refer to ../include/page0zip.ic for a description of the
compressed page format. */
#ifndef UNIV_INNOCHECKSUM
/* The infimum and supremum records are omitted from the compressed page.
On compress, we compare that the records are there, and on uncompress we
restore the records. */
......@@ -105,6 +118,8 @@ static const byte supremum_extra_data[] = {
0x65, 0x6d, 0x75, 0x6d /* "supremum" */
};
#endif /* !UNIV_INNOCHECKSUM */
/** Assert that a block of memory is filled with zero bytes.
Compare at most sizeof(field_ref_zero) bytes.
@param b in: memory block
......@@ -151,6 +166,7 @@ page_zip_fail_func(
# define page_zip_fail(fmt_args) /* empty */
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
#ifndef UNIV_INNOCHECKSUM
#ifndef UNIV_HOTBACKUP
/**********************************************************************//**
Determine the guaranteed free space on an empty page.
......@@ -4843,6 +4859,7 @@ page_zip_parse_compress(
return(ptr + 8 + size + trailer_size);
}
#endif /* !UNIV_INNOCHECKSUM */
/**********************************************************************//**
Calculate the compressed page checksum.
......@@ -4918,6 +4935,10 @@ page_zip_verify_checksum(
stored = static_cast<ib_uint32_t>(mach_read_from_4(
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
#error "FIL_PAGE_LSN must be 64 bit aligned"
#endif
......@@ -4938,40 +4959,113 @@ page_zip_verify_checksum(
return(TRUE);
}
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(
data, size, static_cast<srv_checksum_algorithm_t>(
srv_checksum_algorithm)));
data, size, curr_algo));
if (stored == calc) {
return(TRUE);
}
switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) {
switch (curr_algo) {
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:
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);
}
crc32 = calc;
innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_INNODB));
if (stored == innodb) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
}
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(
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;
case SRV_CHECKSUM_ALGORITHM_NONE:
return(TRUE);
ut_error;
/* no default so the compiler will emit a warning if new enum
is added and not handled here */
}
return(stored == crc32 || stored == innodb);
return(FALSE);
}
......@@ -2738,6 +2738,8 @@ row_ins_sec_index_entry_low(
goto func_exit;
}
DEBUG_SYNC_C("row_ins_sec_index_entry_dup_locks_created");
/* We did not find a duplicate and we have now
locked with s-locks the necessary records to
prevent any insertion of a duplicate by another
......
/*****************************************************************************
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) 2013, 2014, MariaDB Corporation. All Rights Reserved.
......@@ -1192,8 +1192,8 @@ sync_array_print_info_low(
ulint count = 0;
fprintf(file,
"OS WAIT ARRAY INFO: reservation count %ld\n",
(long) arr->res_count);
"OS WAIT ARRAY INFO: reservation count " ULINTPF "\n",
arr->res_count);
for (i = 0; count < arr->n_reserved; ++i) {
sync_cell_t* cell;
......@@ -1289,7 +1289,7 @@ sync_array_print(
}
fprintf(file,
"OS WAIT ARRAY INFO: signal count %ld\n", (long) sg_count);
"OS WAIT ARRAY INFO: signal count " ULINTPF "\n", sg_count);
}
......
......@@ -1196,8 +1196,6 @@ trx_sys_close(void)
/* Free the double write data structures. */
buf_dblwr_free();
mutex_enter(&trx_sys->mutex);
ut_a(UT_LIST_GET_LEN(trx_sys->ro_trx_list) == 0);
/* Only prepared transactions may be left in the system. Free them. */
......@@ -1237,8 +1235,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->mysql_trx_list) == 0);
mutex_exit(&trx_sys->mutex);
mutex_free(&trx_sys->mutex);
ut_ad(trx_sys->descr_n_used == 0);
......
/*****************************************************************************
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
the terms of the GNU General Public License as published by the Free Software
......@@ -476,9 +476,7 @@ trx_free_prepared(
ut_a(trx_state_eq(trx, TRX_STATE_PREPARED));
ut_a(trx->magic_n == TRX_MAGIC_N);
mutex_exit(&trx_sys->mutex);
lock_trx_release_locks(trx);
mutex_enter(&trx_sys->mutex);
trx_undo_free_prepared(trx);
assert_trx_in_rw_list(trx);
......@@ -488,7 +486,9 @@ trx_free_prepared(
UT_LIST_REMOVE(trx_list, trx_sys->rw_trx_list, trx);
ut_d(trx->in_rw_trx_list = FALSE);
mutex_enter(&trx_sys->mutex);
trx_release_descriptor(trx);
mutex_exit(&trx_sys->mutex);
/* Undo trx_resurrect_table_locks(). */
UT_LIST_INIT(trx->lock.trx_locks);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment