Skip to content

Commit a65162a

Browse files
committed
Merge branch 'merge-innodb-5.6' into 10.0
2 parents 909f760 + 139ba26 commit a65162a

File tree

16 files changed

+437
-237
lines changed

16 files changed

+437
-237
lines changed

storage/innobase/api/api0api.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,21 @@ ib_trx_begin(
595595
return(static_cast<ib_trx_t>(trx));
596596
}
597597

598+
599+
/*****************************************************************//**
600+
Check if transaction is read_only
601+
@return transaction read_only status */
602+
UNIV_INTERN
603+
ib_u32_t
604+
ib_trx_read_only(
605+
/*=============*/
606+
ib_trx_t ib_trx) /*!< in: trx handle */
607+
{
608+
trx_t* trx = (trx_t*) ib_trx;
609+
610+
return(trx->read_only);
611+
}
612+
598613
/*****************************************************************//**
599614
Get the transaction's state.
600615
@return transaction state */

storage/innobase/buf/buf0buf.cc

Lines changed: 162 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2008, Google Inc.
55
66
Portions of this file contain modifications contributed and copyrighted by
@@ -486,6 +486,79 @@ buf_page_is_zeroes(
486486
return(true);
487487
}
488488

489+
/** Checks if the page is in crc32 checksum format.
490+
@param[in] read_buf database page
491+
@param[in] checksum_field1 new checksum field
492+
@param[in] checksum_field2 old checksum field
493+
@return true if the page is in crc32 checksum format */
494+
UNIV_INLINE
495+
bool
496+
buf_page_is_checksum_valid_crc32(
497+
const byte* read_buf,
498+
ulint checksum_field1,
499+
ulint checksum_field2)
500+
{
501+
ib_uint32_t crc32 = buf_calc_page_crc32(read_buf);
502+
503+
return(checksum_field1 == crc32 && checksum_field2 == crc32);
504+
}
505+
506+
/** Checks if the page is in innodb checksum format.
507+
@param[in] read_buf database page
508+
@param[in] checksum_field1 new checksum field
509+
@param[in] checksum_field2 old checksum field
510+
@return true if the page is in innodb checksum format */
511+
UNIV_INLINE
512+
bool
513+
buf_page_is_checksum_valid_innodb(
514+
const byte* read_buf,
515+
ulint checksum_field1,
516+
ulint checksum_field2)
517+
{
518+
/* There are 2 valid formulas for
519+
checksum_field2 (old checksum field) which algo=innodb could have
520+
written to the page:
521+
522+
1. Very old versions of InnoDB only stored 8 byte lsn to the
523+
start and the end of the page.
524+
525+
2. Newer InnoDB versions store the old formula checksum
526+
(buf_calc_page_old_checksum()). */
527+
528+
if (checksum_field2 != mach_read_from_4(read_buf + FIL_PAGE_LSN)
529+
&& checksum_field2 != buf_calc_page_old_checksum(read_buf)) {
530+
return(false);
531+
}
532+
533+
/* old field is fine, check the new field */
534+
535+
/* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
536+
(always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
537+
538+
if (checksum_field1 != 0
539+
&& checksum_field1 != buf_calc_page_new_checksum(read_buf)) {
540+
return(false);
541+
}
542+
543+
return(true);
544+
}
545+
546+
/** Checks if the page is in none checksum format.
547+
@param[in] read_buf database page
548+
@param[in] checksum_field1 new checksum field
549+
@param[in] checksum_field2 old checksum field
550+
@return true if the page is in none checksum format */
551+
UNIV_INLINE
552+
bool
553+
buf_page_is_checksum_valid_none(
554+
const byte* read_buf,
555+
ulint checksum_field1,
556+
ulint checksum_field2)
557+
{
558+
return(checksum_field1 == checksum_field2
559+
&& checksum_field1 == BUF_NO_CHECKSUM_MAGIC);
560+
}
561+
489562
/********************************************************************//**
490563
Checks if a page is corrupt.
491564
@return TRUE if corrupted */
@@ -501,8 +574,6 @@ buf_page_is_corrupted(
501574
{
502575
ulint checksum_field1;
503576
ulint checksum_field2;
504-
ibool crc32_inited = FALSE;
505-
ib_uint32_t crc32 = ULINT32_UNDEFINED;
506577

507578
if (!zip_size
508579
&& memcmp(read_buf + FIL_PAGE_LSN + 4,
@@ -582,148 +653,121 @@ buf_page_is_corrupted(
582653
return(FALSE);
583654
}
584655

585-
switch ((srv_checksum_algorithm_t) srv_checksum_algorithm) {
586-
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
587-
588-
crc32 = buf_calc_page_crc32(read_buf);
589-
590-
return(checksum_field1 != crc32 || checksum_field2 != crc32);
591-
592-
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
593-
594-
return(checksum_field1
595-
!= buf_calc_page_new_checksum(read_buf)
596-
|| checksum_field2
597-
!= buf_calc_page_old_checksum(read_buf));
598-
599-
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
656+
DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); );
600657

601-
return(checksum_field1 != BUF_NO_CHECKSUM_MAGIC
602-
|| checksum_field2 != BUF_NO_CHECKSUM_MAGIC);
658+
ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET);
659+
ulint space_id = mach_read_from_4(read_buf + FIL_PAGE_SPACE_ID);
660+
const srv_checksum_algorithm_t curr_algo =
661+
static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
603662

663+
switch (curr_algo) {
604664
case SRV_CHECKSUM_ALGORITHM_CRC32:
605-
case SRV_CHECKSUM_ALGORITHM_INNODB:
606-
/* There are 3 valid formulas for
607-
checksum_field2 (old checksum field):
608-
609-
1. Very old versions of InnoDB only stored 8 byte lsn to the
610-
start and the end of the page.
611-
612-
2. InnoDB versions before MySQL 5.6.3 store the old formula
613-
checksum (buf_calc_page_old_checksum()).
614-
615-
3. InnoDB versions 5.6.3 and newer with
616-
innodb_checksum_algorithm=strict_crc32|crc32 store CRC32. */
617-
618-
/* since innodb_checksum_algorithm is not strict_* allow
619-
any of the algos to match for the old field */
620-
621-
if (checksum_field2
622-
!= mach_read_from_4(read_buf + FIL_PAGE_LSN)
623-
&& checksum_field2 != BUF_NO_CHECKSUM_MAGIC) {
624-
625-
/* The checksum does not match any of the
626-
fast to check. First check the selected algorithm
627-
for writing checksums because we assume that the
628-
chance of it matching is higher. */
629-
630-
if (srv_checksum_algorithm
631-
== SRV_CHECKSUM_ALGORITHM_CRC32) {
632-
633-
crc32 = buf_calc_page_crc32(read_buf);
634-
crc32_inited = TRUE;
635-
636-
if (checksum_field2 != crc32
637-
&& checksum_field2
638-
!= buf_calc_page_old_checksum(read_buf)) {
665+
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
639666

640-
return(TRUE);
641-
}
642-
} else {
643-
ut_ad(srv_checksum_algorithm
644-
== SRV_CHECKSUM_ALGORITHM_INNODB);
667+
if (buf_page_is_checksum_valid_crc32(read_buf,
668+
checksum_field1, checksum_field2)) {
669+
return(FALSE);
670+
}
645671

646-
if (checksum_field2
647-
!= buf_calc_page_old_checksum(read_buf)) {
672+
if (buf_page_is_checksum_valid_none(read_buf,
673+
checksum_field1, checksum_field2)) {
674+
if (curr_algo
675+
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
676+
page_warn_strict_checksum(
677+
curr_algo,
678+
SRV_CHECKSUM_ALGORITHM_NONE,
679+
space_id, page_no);
680+
}
648681

649-
crc32 = buf_calc_page_crc32(read_buf);
650-
crc32_inited = TRUE;
682+
return(FALSE);
683+
}
651684

652-
if (checksum_field2 != crc32) {
653-
return(TRUE);
654-
}
655-
}
685+
if (buf_page_is_checksum_valid_innodb(read_buf,
686+
checksum_field1, checksum_field2)) {
687+
if (curr_algo
688+
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
689+
page_warn_strict_checksum(
690+
curr_algo,
691+
SRV_CHECKSUM_ALGORITHM_INNODB,
692+
space_id, page_no);
656693
}
657-
}
658694

659-
/* old field is fine, check the new field */
695+
return(FALSE);
696+
}
660697

661-
/* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
662-
(always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
698+
return(TRUE);
663699

664-
if (checksum_field1 != 0
665-
&& checksum_field1 != BUF_NO_CHECKSUM_MAGIC) {
700+
case SRV_CHECKSUM_ALGORITHM_INNODB:
701+
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
666702

667-
/* The checksum does not match any of the
668-
fast to check. First check the selected algorithm
669-
for writing checksums because we assume that the
670-
chance of it matching is higher. */
703+
if (buf_page_is_checksum_valid_innodb(read_buf,
704+
checksum_field1, checksum_field2)) {
705+
return(FALSE);
706+
}
671707

672-
if (srv_checksum_algorithm
673-
== SRV_CHECKSUM_ALGORITHM_CRC32) {
708+
if (buf_page_is_checksum_valid_none(read_buf,
709+
checksum_field1, checksum_field2)) {
710+
if (curr_algo
711+
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
712+
page_warn_strict_checksum(
713+
curr_algo,
714+
SRV_CHECKSUM_ALGORITHM_NONE,
715+
space_id, page_no);
716+
}
674717

675-
if (!crc32_inited) {
676-
crc32 = buf_calc_page_crc32(read_buf);
677-
crc32_inited = TRUE;
678-
}
718+
return(FALSE);
719+
}
679720

680-
if (checksum_field1 != crc32
681-
&& checksum_field1
682-
!= buf_calc_page_new_checksum(read_buf)) {
721+
if (buf_page_is_checksum_valid_crc32(read_buf,
722+
checksum_field1, checksum_field2)) {
723+
if (curr_algo
724+
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
725+
page_warn_strict_checksum(
726+
curr_algo,
727+
SRV_CHECKSUM_ALGORITHM_CRC32,
728+
space_id, page_no);
729+
}
683730

684-
return(TRUE);
685-
}
686-
} else {
687-
ut_ad(srv_checksum_algorithm
688-
== SRV_CHECKSUM_ALGORITHM_INNODB);
731+
return(FALSE);
732+
}
689733

690-
if (checksum_field1
691-
!= buf_calc_page_new_checksum(read_buf)) {
734+
return(TRUE);
692735

693-
if (!crc32_inited) {
694-
crc32 = buf_calc_page_crc32(
695-
read_buf);
696-
crc32_inited = TRUE;
697-
}
736+
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
698737

699-
if (checksum_field1 != crc32) {
700-
return(TRUE);
701-
}
702-
}
703-
}
738+
if (buf_page_is_checksum_valid_none(read_buf,
739+
checksum_field1, checksum_field2)) {
740+
return(FALSE);
704741
}
705742

706-
/* If CRC32 is stored in at least one of the fields, then the
707-
other field must also be CRC32 */
708-
if (crc32_inited
709-
&& ((checksum_field1 == crc32
710-
&& checksum_field2 != crc32)
711-
|| (checksum_field1 != crc32
712-
&& checksum_field2 == crc32))) {
743+
if (buf_page_is_checksum_valid_crc32(read_buf,
744+
checksum_field1, checksum_field2)) {
745+
page_warn_strict_checksum(
746+
curr_algo,
747+
SRV_CHECKSUM_ALGORITHM_CRC32,
748+
space_id, page_no);
749+
return(FALSE);
750+
}
713751

714-
return(TRUE);
752+
if (buf_page_is_checksum_valid_innodb(read_buf,
753+
checksum_field1, checksum_field2)) {
754+
page_warn_strict_checksum(
755+
curr_algo,
756+
SRV_CHECKSUM_ALGORITHM_INNODB,
757+
space_id, page_no);
758+
return(FALSE);
715759
}
716760

717-
break;
761+
return(TRUE);
762+
718763
case SRV_CHECKSUM_ALGORITHM_NONE:
719764
/* should have returned FALSE earlier */
720-
ut_error;
765+
break;
721766
/* no default so the compiler will emit a warning if new enum
722767
is added and not handled here */
723768
}
724769

725-
DBUG_EXECUTE_IF("buf_page_is_corrupt_failure", return(TRUE); );
726-
770+
ut_error;
727771
return(FALSE);
728772
}
729773

@@ -1673,6 +1717,9 @@ buf_pool_watch_set(
16731717
goto page_found;
16741718
}
16751719

1720+
/* The maximum number of purge threads should never exceed
1721+
BUF_POOL_WATCH_SIZE. So there is no way for purge thread
1722+
instance to hold a watch when setting another watch. */
16761723
for (i = 0; i < BUF_POOL_WATCH_SIZE; i++) {
16771724
bpage = &buf_pool->watch[i];
16781725

storage/innobase/buf/buf0checksum.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 1995, 2011, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -139,14 +139,17 @@ buf_checksum_algorithm_name(
139139
{
140140
switch (algo) {
141141
case SRV_CHECKSUM_ALGORITHM_CRC32:
142-
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
143142
return("crc32");
143+
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
144+
return("strict_crc32");
144145
case SRV_CHECKSUM_ALGORITHM_INNODB:
145-
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
146146
return("innodb");
147+
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
148+
return("strict_innodb");
147149
case SRV_CHECKSUM_ALGORITHM_NONE:
148-
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
149150
return("none");
151+
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
152+
return("strict_none");
150153
}
151154

152155
ut_error;

0 commit comments

Comments
 (0)